cioraneanu / firefly-pico

A delightful Firefly III companion web app for effortless transaction tracking
GNU Affero General Public License v3.0
429 stars 19 forks source link

Persist UI settings in database #79

Closed avee87 closed 4 months ago

avee87 commented 5 months ago

Exploring implementation for #31 For now just for UI settings such as dark mode and lowercasing things.

Settings are keyed on app token but I also hash it to prevent storing it in database as is.

cioraneanu commented 5 months ago

Some observations:

      // Before
      this.ui.darkTheme = newValues.darkTheme
      this.ui.numberFormat = newValues.numberFormat

      // After
      for (let key as Object.keys(newValues)) {
           this.ui[key] = newValues[key]
      }
cioraneanu commented 5 months ago

Nice! Already looks way better. A few more observations:

avee87 commented 5 months ago

the new endpoints should be REST like: GET /api/profiles/\

It’s not hash, it’s full access token which is insanely long. I’m not sure it’s a good idea to pass it as part of the path.

cioraneanu commented 5 months ago

Indeed. Then I guess we can just remove it, have the route as GET /api/profiles and read the token from the Authorization header.

Also in the new DB migration let's create a primary key "id" to future proof it. This way we can later turn it into a classic REST approach (ex. Let the user manage multiple profile settings)

cioraneanu commented 4 months ago

Awesome contribution! 🚀 ❤️