-
Notifications
You must be signed in to change notification settings - Fork 106
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
Implement alert for unsaved changes #343
base: master
Are you sure you want to change the base?
Conversation
Well, we could discuss some implementation details. |
@@ -595,12 +595,37 @@ export class GeneralOptions implements Cloneable { | |||
this.themesDark = source['themesDark']; | |||
this.themesDarkCustomUrl = source['themesDarkCustomUrl']; | |||
} | |||
|
|||
Equals(other: GeneralOptions): Boolean { |
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 method is not gonna work well. Settings could come from different locations like sync, backups and etc and might miss some properties.
This method should treat null/undefined and empty values as same
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.
with neq
function it should now
src/ui/code/settingsPage.ts
Outdated
@@ -2186,6 +2219,10 @@ export class settingsPage { | |||
settingsPage.updateProfileGridsLayout(pageSmartProfile); | |||
settingsPage.selectAddNewProfileMenu(); | |||
|
|||
settingsPage.unsavedProfile = pageSmartProfile; |
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'm not happy to keep a reference of pageSmartProfile
in the page level, we can be more smart about this.
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, i don't like this too, but i couldn't find a way to find if there's an unsaved profile (and get its page object) when leaving the page.
Thanks for the write up, overall looking good but I've left some comments. I've pushed a clean up commit as well. Please fix the conflicts while you are at it |
For #296
There's two model: 1) Tracking if changed (not very accurately ie: Enable and disable and then enable is still treated as changed) 2) Comparison between current and original
It looks like SmartProxy has implemented some basic objection for tracking (settingsPage.changeTracking). So I use the tracking model for most changes.
However , it's hard/(too complex) to apply tacking model on
GeneralOptions
, But comparison is suitable here.Also
changeTracking
to false when runtimeSendMessage(SettingsPageSave*) is called.Note:
changeTracking .rulesSubscriptions should also set to false in onClickSaveSmartProfile ( same as changeTracking.smartProfile )