FIX: Notification ring backdrop might get triggered more than once.

This commit is contained in:
Guo Xiang Tan 2016-11-16 11:37:13 +08:00
parent 239cbc6e68
commit 10068f86b6
1 changed files with 7 additions and 6 deletions

View File

@ -20,8 +20,6 @@ const dropdown = {
} }
}; };
let hideRingBackdrop = false;
createWidget('header-notifications', { createWidget('header-notifications', {
settings: { settings: {
avatarSize: 'medium' avatarSize: 'medium'
@ -46,9 +44,8 @@ createWidget('header-notifications', {
if (!!unreadPMs) { if (!!unreadPMs) {
if (!currentUser.get('read_first_notification')) { if (!currentUser.get('read_first_notification')) {
contents.push(h('span.ring')); contents.push(h('span.ring'));
if (!attrs.active && !hideRingBackdrop) { if (!attrs.active && attrs.ringBackdrop) {
contents.push(h('span.ring-backdrop')); contents.push(h('span.ring-backdrop'));
hideRingBackdrop = true;
} }
}; };
@ -132,7 +129,8 @@ createWidget('header-icons', {
const icons = [search, hamburger]; const icons = [search, hamburger];
if (this.currentUser) { if (this.currentUser) {
icons.push(this.attach('user-dropdown', { active: attrs.userVisible, icons.push(this.attach('user-dropdown', { active: attrs.userVisible,
action: 'toggleUserMenu' })); action: 'toggleUserMenu',
ringBackdrop: attrs.ringBackdrop }));
} }
return icons; return icons;
@ -170,7 +168,8 @@ export default createWidget('header', {
return { searchVisible: false, return { searchVisible: false,
hamburgerVisible: false, hamburgerVisible: false,
userVisible: false, userVisible: false,
contextEnabled: false }; contextEnabled: false,
ringBackdrop: true };
}, },
html(attrs, state) { html(attrs, state) {
@ -178,6 +177,7 @@ export default createWidget('header', {
this.attach('header-icons', { hamburgerVisible: state.hamburgerVisible, this.attach('header-icons', { hamburgerVisible: state.hamburgerVisible,
userVisible: state.userVisible, userVisible: state.userVisible,
searchVisible: state.searchVisible, searchVisible: state.searchVisible,
ringBackdrop: state.ringBackdrop,
flagCount: attrs.flagCount })]; flagCount: attrs.flagCount })];
if (state.searchVisible) { if (state.searchVisible) {
@ -238,6 +238,7 @@ export default createWidget('header', {
}, },
toggleUserMenu() { toggleUserMenu() {
this.state.ringBackdrop = false;
this.state.userVisible = !this.state.userVisible; this.state.userVisible = !this.state.userVisible;
}, },