This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 827
notification issue fixed #240
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
98343a0
notification issue fixed
mebjas 1875377
Some style fixes
mebjas 818299d
persistent = true, as default param in setToolbarHidden() method
mebjas cbcf23f
funciton name changed to
mebjas 349b472
logic to show/hide toolbar shifted to MatrixChat::render
mebjas 9b5519e
promise -> callback & setToolbarPersistantHidden moved inline
mebjas 8191eaa
unwanted functions removed, prev functions modified
mebjas 8605ca1
comment removed and localStorage update moved up
mebjas 6fc0aae
setToolbarHidden(false) if setEnabled has enable = true
mebjas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,38 +133,31 @@ var Notifier = { | |
} | ||
|
||
if(enable) { | ||
if (!this.havePermission()) { | ||
global.Notification.requestPermission(function() { | ||
if (callback) { | ||
callback(); | ||
dis.dispatch({ | ||
action: "notifier_enabled", | ||
value: true | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
if (!global.localStorage) return; | ||
global.localStorage.setItem('notifications_enabled', 'true'); | ||
|
||
if (this.havePermission) { | ||
// Case when we do not have the permission as 'granted' | ||
// Attempt to get permission from user | ||
global.Notification.requestPermission(function(result) { | ||
if (result !== 'granted') { | ||
// The permission request was dismissed or denied | ||
return; | ||
} | ||
|
||
if (callback) callback(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to update the localStorage setting before you run the callback and dispatch the |
||
dis.dispatch({ | ||
action: "notifier_enabled", | ||
value: true | ||
}); | ||
} | ||
} | ||
else { | ||
|
||
if (!global.localStorage) return; | ||
global.localStorage.setItem('notifications_enabled', 'true'); | ||
}); | ||
} else { | ||
if (!global.localStorage) return; | ||
global.localStorage.setItem('notifications_enabled', 'false'); | ||
dis.dispatch({ | ||
action: "notifier_enabled", | ||
value: false | ||
}); | ||
} | ||
|
||
this.setToolbarHidden(false); | ||
}, | ||
|
||
isEnabled: function() { | ||
|
@@ -192,15 +185,27 @@ var Notifier = { | |
return enabled === 'true'; | ||
}, | ||
|
||
setToolbarHidden: function(hidden) { | ||
setToolbarHidden: function(hidden, persistent = true) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just fyi: you may know this already but default parameters are a feature of ES6, which means that we can't use them in some browsers. But it's ok to use in react-sdk because babel translates it for us. |
||
this.toolbarHidden = hidden; | ||
dis.dispatch({ | ||
action: "notifier_enabled", | ||
value: this.isEnabled() | ||
}); | ||
|
||
// update the info to localStorage for persistent settings | ||
if (persistent && global.localStorage) { | ||
global.localStorage.setItem('notifications_hidden', 'true'); | ||
} | ||
}, | ||
|
||
isToolbarHidden: function() { | ||
// Check localStorage for any such meta data | ||
if (global.localStorage) { | ||
if (global.localStorage.getItem('notifications_hidden') === 'true') { | ||
return true; | ||
} | ||
} | ||
|
||
return this.toolbarHidden; | ||
}, | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 comment is no longer helpful