dev/server-sync-settings#306
Conversation
Codecov Report
@@ Coverage Diff @@
## master #306 +/- ##
==========================================
- Coverage 15.91% 15.70% -0.21%
==========================================
Files 24 25 +1
Lines 1194 1165 -29
Branches 134 127 -7
==========================================
- Hits 190 183 -7
+ Misses 959 938 -21
+ Partials 45 44 -1
Continue to review full report at Codecov.
|
ErikBjare
left a comment
There was a problem hiding this comment.
Good progress so far, looks like next step is putting it in Vuex and start to refactor some uses of localStorage in the code.
| { | ||
| "editor.formatOnSave": true | ||
| } No newline at end of file |
There was a problem hiding this comment.
You can omit this, and add .vscode to .gitignore
| data() { | ||
| return { | ||
| settingsData: { | ||
| durationDefault: '86400', | ||
| initialTimestamp: 'Thu Sep 23 2021 15:22:08 GMT+0530', | ||
| newReleaseCheckData: | ||
| '{"isEnabled":true,"nextCheckTime":"2021-09-29T09:51:36.782Z","howOftenToCheck":86400,"timesChecked":0}', | ||
| startOfDay: '04:00', | ||
| syncSettingsToServer: true, | ||
| userSatisfactionPollData: | ||
| '{"isEnabled":true,"nextPollTime":"2021-09-30T09:52:08.703Z","timesPollIsShown":0}', | ||
| }, | ||
| }; | ||
| }, | ||
| async created() { | ||
| await this.init(); | ||
| }, | ||
| methods: { | ||
| async init() { | ||
| // read data from localstorage | ||
| const { | ||
| syncSettingsToServer, | ||
| startOfDay, | ||
| newReleaseCheckData, | ||
| initialTimestamp, | ||
| durationDefault, | ||
| userSatisfactionPollData, | ||
| } = localStorage; | ||
|
|
||
| // check if its a new user and set sync accordingly | ||
| await this.checkNewUser(syncSettingsToServer, durationDefault); | ||
|
|
||
| let data; | ||
| // if server sync enabled, get settings from server | ||
| if (syncSettingsToServer) { | ||
| data = await getSettingsFromServer(); | ||
| } else { | ||
| data = { | ||
| syncSettingsToServer, | ||
| startOfDay, | ||
| newReleaseCheckData, | ||
| initialTimestamp, | ||
| durationDefault, | ||
| userSatisfactionPollData, | ||
| }; | ||
| } | ||
| this.settingsData = data; | ||
| return; | ||
| }, | ||
| async checkNewUser(syncSettingsToServer, durationDefault) { | ||
| if (syncSettingsToServer == undefined) { | ||
| // sync property doesn't exist | ||
| if (durationDefault) { | ||
| // existing user, set sync to false by default | ||
| localStorage.setItem('syncSettingsToServer', 'false'); | ||
| } else { | ||
| // new user, keep sync on by default | ||
| localStorage.setItem('syncSettingsToServer', 'true'); | ||
| } | ||
| } | ||
| return; | ||
| }, |
There was a problem hiding this comment.
Stuff like this should definitely go in a Vuex module.
| this.settingsData.syncSettingsToServer = !this.settingsData.syncSettingsToServer; | ||
| updateSettingOnServer('syncSettingsToServer', this.settingsData.syncSettingsToServer); |
There was a problem hiding this comment.
Probably need to set the keys one-by-one (unless the API allows something else).
Perhaps the settings keys should be prefixed with setting or config, such that startOfDay becomes config.startOfDay (just in case we want to use the key-value store for something else as well).
added overflow: visible; to VisTimeline.vue to allow tooltip to overflow the container
remove unwanted z-index change from tooltip.js
aed59ea to
2b6279c
Compare
|
Continued work in #327, closing. |
sync settings to server