-
-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: keep panes settings after reload #2888
fix: keep panes settings after reload #2888
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for the most part. However, using local storage directly is problematic since there can be more than 1 account signed in and all of them might want to have different settings toggled.
Instead, the existing local preferences system (preferences.getLocalValue
/preferences.setLocalValue
) should be used.
04eb169
to
ea03be7
Compare
Ok thank you, I see. Initialize: Toggle: But somehow it always takes the default value provided in |
That's probably because the storage hasnt been decrypted yet. You'll want to handle the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you've changed the incorrect file. .d.ts
files aren't supposed to be modified directly. This whole file shouldn't be in git since it is generated from the original PrefDefaults.ts
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I get that, but in order to access the values in PrefDefaults.ts
, I would have to add them to PrefKeys.ts
and so what is the point of using LocalPrefKeys.ts
? Should I just use PrefKeys.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or should I just use it like this, without the default stuff, since it is only a boolean value:
listPaneExplicitelyCollapsed = this.preferences.getLocalValue(LocalPrefKey.ListPaneCollapsed, false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially all the properties in LocalPrefKey
were synced so they were in the PrefKey
and so they still use PrefDefaults
.
You can just create a LocalPrefDefaults
similar to the PrefDefaults
in the LocalPrefKey.ts
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We keep all the defaults in a constant so that there's a single source of truth in case those might need to be used somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do you mean in LocalPrefKey.ts
add this:
export declare const LocalPrefDefaults: {
listPaneCollapsed: false;
navigationPaneCollapsed: false;
}
and use it like this:
listPaneExplicitelyCollapsed = this.preferences.getLocalValue(LocalPrefKey.ListPaneCollapsed, LocalPrefDefaults[LocalPrefKey.ListPaneCollapsed])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
7eb2e62
to
6e222cf
Compare
I tried this out locally and the setting does seem to get correctly persisted, but the actual pane removal logic doesn't seem to work on reload? If I turn off the items list, it doesn't stay turned off on reload but from logging I can see that the value has been stored correctly. |
Ok, I could reproduce it: I normally use Arc Browser (which is chromium based) and it works as expected. However if I try it in Chrome or Edge, I get the same behaviour as you described above. |
I did a lot of testing and found out some inconsistencies: First of all this is not browser related because I noticed the same behaviour for chrome and edge. First weird behaviour: Second weird behaviour: So i guess if you type somthing into a note, you should be able to see the intended behaviour of my implementation. I am currently looking into why |
After some more testing, I don't know how to resolve the problem with the account menu popup, but I found, that for example in line 96 of So this is not a problem of |
The theme-related settings which also use LocalPrefKeys work correctly on empty workspaces, so this not working there is a bug. I think what you'll probably want to do is instead of running this initialization logic in the constructor, you'll want to run it the first time |
Btw this is not a bug, it's intended behavior. If the workspace is fresh, we always show the account menu on load so that the user can quickly create an account or sign in. |
This seems to work, thank you. I will change it and push it in a minute. |
LocalPrefKey.NavigationPaneCollapsed, | ||
LocalPrefDefaults[LocalPrefKey.NavigationPaneCollapsed], | ||
) | ||
const screen = this._isTabletOrMobileScreen.execute().getValue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will now run after every setLocalValue
call, no? i think it makes more sense to have a boolean in the class to make sure this only runs once since its supposed to be initialization logic.
i was talking about the whole initialization logic, not the particular line 🙂 a boolean like |
Ah ok sorry, that makes sense.
should i put the |
yes
yes. technically the value of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to go now, thanks for the PR!
This fixes the issue mentioned here: standardnotes/forum#2423
I used
localStorage
to save the changes made by toggeling the panes.Also I edited the initialization of the
panes
array, because otherwise all three panes would show up after reload for a short time and then dissapear again depending on your settings.