diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-12-02 21:11:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-02 21:11:38 +0100 |
commit | 4e42a6f8c3000889b6ef42ebcdf8d9b8d8bce930 (patch) | |
tree | 26fc32df8f4eddf26c7bdc185b91bbd458adddf1 | |
parent | Merge pull request #359 from jaebradley/fix-i-want-add-services-manually-typo (diff) | |
parent | fix missing filter for indirectMessageBadge (diff) | |
download | ferdium-app-4e42a6f8c3000889b6ef42ebcdf8d9b8d8bce930.tar.gz ferdium-app-4e42a6f8c3000889b6ef42ebcdf8d9b8d8bce930.tar.zst ferdium-app-4e42a6f8c3000889b6ef42ebcdf8d9b8d8bce930.zip |
Merge pull request #386 from meetfranz/feature/improve-mute
[PR] Improve mute
-rw-r--r-- | src/actions/app.js | 1 | ||||
-rw-r--r-- | src/components/layout/Sidebar.js | 8 | ||||
-rw-r--r-- | src/components/services/tabs/TabBarSortableList.js | 6 | ||||
-rw-r--r-- | src/components/services/tabs/TabItem.js | 37 | ||||
-rw-r--r-- | src/components/services/tabs/Tabbar.js | 6 | ||||
-rw-r--r-- | src/components/settings/settings/EditSettingsForm.js | 1 | ||||
-rw-r--r-- | src/config.js | 1 | ||||
-rw-r--r-- | src/containers/layout/AppLayoutContainer.js | 8 | ||||
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 10 | ||||
-rw-r--r-- | src/i18n/locales/en-US.json | 5 | ||||
-rw-r--r-- | src/models/Settings.js | 1 | ||||
-rw-r--r-- | src/stores/AppStore.js | 25 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 17 | ||||
-rw-r--r-- | src/stores/SettingsStore.js | 3 | ||||
-rw-r--r-- | src/stores/UIStore.js | 8 | ||||
-rw-r--r-- | src/styles/tabs.scss | 20 |
16 files changed, 125 insertions, 32 deletions
diff --git a/src/actions/app.js b/src/actions/app.js index 25ff9344d..e4f648fc9 100644 --- a/src/actions/app.js +++ b/src/actions/app.js | |||
@@ -22,6 +22,7 @@ export default { | |||
22 | healthCheck: {}, | 22 | healthCheck: {}, |
23 | muteApp: { | 23 | muteApp: { |
24 | isMuted: PropTypes.bool.isRequired, | 24 | isMuted: PropTypes.bool.isRequired, |
25 | overrideSystemMute: PropTypes.bool, | ||
25 | }, | 26 | }, |
26 | toggleMuteApp: {}, | 27 | toggleMuteApp: {}, |
27 | }; | 28 | }; |
diff --git a/src/components/layout/Sidebar.js b/src/components/layout/Sidebar.js index cb2ecc8ce..915ebeace 100644 --- a/src/components/layout/Sidebar.js +++ b/src/components/layout/Sidebar.js | |||
@@ -17,12 +17,12 @@ const messages = defineMessages({ | |||
17 | defaultMessage: '!!!Add new service', | 17 | defaultMessage: '!!!Add new service', |
18 | }, | 18 | }, |
19 | mute: { | 19 | mute: { |
20 | id: 'sidebar.mute', | 20 | id: 'sidebar.muteApp', |
21 | defaultMessage: '!!!Disable audio', | 21 | defaultMessage: '!!!Disable notifications & audio', |
22 | }, | 22 | }, |
23 | unmute: { | 23 | unmute: { |
24 | id: 'sidebar.unmute', | 24 | id: 'sidebar.unmuteApp', |
25 | defaultMessage: '!!!Enable audio', | 25 | defaultMessage: '!!!Enable notifications & audio', |
26 | }, | 26 | }, |
27 | }); | 27 | }); |
28 | 28 | ||
diff --git a/src/components/services/tabs/TabBarSortableList.js b/src/components/services/tabs/TabBarSortableList.js index 2daf55676..489027d57 100644 --- a/src/components/services/tabs/TabBarSortableList.js +++ b/src/components/services/tabs/TabBarSortableList.js | |||
@@ -17,6 +17,8 @@ class TabBarSortableList extends Component { | |||
17 | deleteService: PropTypes.func.isRequired, | 17 | deleteService: PropTypes.func.isRequired, |
18 | disableService: PropTypes.func.isRequired, | 18 | disableService: PropTypes.func.isRequired, |
19 | enableService: PropTypes.func.isRequired, | 19 | enableService: PropTypes.func.isRequired, |
20 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, | ||
21 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, | ||
20 | } | 22 | } |
21 | 23 | ||
22 | render() { | 24 | render() { |
@@ -30,6 +32,8 @@ class TabBarSortableList extends Component { | |||
30 | disableService, | 32 | disableService, |
31 | enableService, | 33 | enableService, |
32 | openSettings, | 34 | openSettings, |
35 | showMessageBadgeWhenMutedSetting, | ||
36 | showMessageBadgesEvenWhenMuted, | ||
33 | } = this.props; | 37 | } = this.props; |
34 | 38 | ||
35 | return ( | 39 | return ( |
@@ -50,6 +54,8 @@ class TabBarSortableList extends Component { | |||
50 | disableService={() => disableService({ serviceId: service.id })} | 54 | disableService={() => disableService({ serviceId: service.id })} |
51 | enableService={() => enableService({ serviceId: service.id })} | 55 | enableService={() => enableService({ serviceId: service.id })} |
52 | openSettings={openSettings} | 56 | openSettings={openSettings} |
57 | showMessageBadgeWhenMutedSetting={showMessageBadgeWhenMutedSetting} | ||
58 | showMessageBadgesEvenWhenMuted={showMessageBadgesEvenWhenMuted} | ||
53 | /> | 59 | /> |
54 | ))} | 60 | ))} |
55 | {/* <li> | 61 | {/* <li> |
diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js index a7136c43f..8403d9462 100644 --- a/src/components/services/tabs/TabItem.js +++ b/src/components/services/tabs/TabItem.js | |||
@@ -63,6 +63,8 @@ class TabItem extends Component { | |||
63 | deleteService: PropTypes.func.isRequired, | 63 | deleteService: PropTypes.func.isRequired, |
64 | disableService: PropTypes.func.isRequired, | 64 | disableService: PropTypes.func.isRequired, |
65 | enableService: PropTypes.func.isRequired, | 65 | enableService: PropTypes.func.isRequired, |
66 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, | ||
67 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, | ||
66 | }; | 68 | }; |
67 | 69 | ||
68 | static contextTypes = { | 70 | static contextTypes = { |
@@ -81,6 +83,8 @@ class TabItem extends Component { | |||
81 | disableService, | 83 | disableService, |
82 | enableService, | 84 | enableService, |
83 | openSettings, | 85 | openSettings, |
86 | showMessageBadgeWhenMutedSetting, | ||
87 | showMessageBadgesEvenWhenMuted, | ||
84 | } = this.props; | 88 | } = this.props; |
85 | const { intl } = this.context; | 89 | const { intl } = this.context; |
86 | 90 | ||
@@ -121,6 +125,26 @@ class TabItem extends Component { | |||
121 | }]; | 125 | }]; |
122 | const menu = Menu.buildFromTemplate(menuTemplate); | 126 | const menu = Menu.buildFromTemplate(menuTemplate); |
123 | 127 | ||
128 | let notificationBadge = null; | ||
129 | if ((showMessageBadgeWhenMutedSetting || service.isNotificationEnabled) && showMessageBadgesEvenWhenMuted) { | ||
130 | notificationBadge = ( | ||
131 | <span> | ||
132 | {service.unreadDirectMessageCount > 0 && ( | ||
133 | <span className="tab-item__message-count"> | ||
134 | {service.unreadDirectMessageCount} | ||
135 | </span> | ||
136 | )} | ||
137 | {service.unreadIndirectMessageCount > 0 | ||
138 | && service.unreadDirectMessageCount === 0 | ||
139 | && service.isIndirectMessageBadgeEnabled && ( | ||
140 | <span className="tab-item__message-count is-indirect"> | ||
141 | • | ||
142 | </span> | ||
143 | )} | ||
144 | </span> | ||
145 | ); | ||
146 | } | ||
147 | |||
124 | return ( | 148 | return ( |
125 | <li | 149 | <li |
126 | className={classnames({ | 150 | className={classnames({ |
@@ -138,18 +162,7 @@ class TabItem extends Component { | |||
138 | className="tab-item__icon" | 162 | className="tab-item__icon" |
139 | alt="" | 163 | alt="" |
140 | /> | 164 | /> |
141 | {service.unreadDirectMessageCount > 0 && ( | 165 | {notificationBadge} |
142 | <span className="tab-item__message-count"> | ||
143 | {service.unreadDirectMessageCount} | ||
144 | </span> | ||
145 | )} | ||
146 | {service.unreadIndirectMessageCount > 0 | ||
147 | && service.unreadDirectMessageCount === 0 | ||
148 | && service.isIndirectMessageBadgeEnabled && ( | ||
149 | <span className="tab-item__message-count is-indirect"> | ||
150 | • | ||
151 | </span> | ||
152 | )} | ||
153 | </li> | 166 | </li> |
154 | ); | 167 | ); |
155 | } | 168 | } |
diff --git a/src/components/services/tabs/Tabbar.js b/src/components/services/tabs/Tabbar.js index 9da1090b7..ceb88c51c 100644 --- a/src/components/services/tabs/Tabbar.js +++ b/src/components/services/tabs/Tabbar.js | |||
@@ -18,6 +18,8 @@ export default class TabBar extends Component { | |||
18 | toggleAudio: PropTypes.func.isRequired, | 18 | toggleAudio: PropTypes.func.isRequired, |
19 | deleteService: PropTypes.func.isRequired, | 19 | deleteService: PropTypes.func.isRequired, |
20 | updateService: PropTypes.func.isRequired, | 20 | updateService: PropTypes.func.isRequired, |
21 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, | ||
22 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, | ||
21 | } | 23 | } |
22 | 24 | ||
23 | onSortEnd = ({ oldIndex, newIndex }) => { | 25 | onSortEnd = ({ oldIndex, newIndex }) => { |
@@ -64,6 +66,8 @@ export default class TabBar extends Component { | |||
64 | toggleNotifications, | 66 | toggleNotifications, |
65 | toggleAudio, | 67 | toggleAudio, |
66 | deleteService, | 68 | deleteService, |
69 | showMessageBadgeWhenMutedSetting, | ||
70 | showMessageBadgesEvenWhenMuted, | ||
67 | } = this.props; | 71 | } = this.props; |
68 | 72 | ||
69 | return ( | 73 | return ( |
@@ -85,6 +89,8 @@ export default class TabBar extends Component { | |||
85 | axis="y" | 89 | axis="y" |
86 | lockAxis="y" | 90 | lockAxis="y" |
87 | helperClass="is-reordering" | 91 | helperClass="is-reordering" |
92 | showMessageBadgeWhenMutedSetting={showMessageBadgeWhenMutedSetting} | ||
93 | showMessageBadgesEvenWhenMuted={showMessageBadgesEvenWhenMuted} | ||
88 | /> | 94 | /> |
89 | </div> | 95 | </div> |
90 | ); | 96 | ); |
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 4ce9b7ab2..878e46d6d 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js | |||
@@ -142,6 +142,7 @@ export default class EditSettingsForm extends Component { | |||
142 | {/* Appearance */} | 142 | {/* Appearance */} |
143 | <h2 id="apperance">{intl.formatMessage(messages.headlineAppearance)}</h2> | 143 | <h2 id="apperance">{intl.formatMessage(messages.headlineAppearance)}</h2> |
144 | <Toggle field={form.$('showDisabledServices')} /> | 144 | <Toggle field={form.$('showDisabledServices')} /> |
145 | <Toggle field={form.$('showMessageBadgeWhenMuted')} /> | ||
145 | 146 | ||
146 | {/* Language */} | 147 | {/* Language */} |
147 | <h2 id="language">{intl.formatMessage(messages.headlineLanguage)}</h2> | 148 | <h2 id="language">{intl.formatMessage(messages.headlineLanguage)}</h2> |
diff --git a/src/config.js b/src/config.js index b3e00c92c..e6d8958e6 100644 --- a/src/config.js +++ b/src/config.js | |||
@@ -11,6 +11,7 @@ export const DEFAULT_APP_SETTINGS = { | |||
11 | enableSystemTray: true, | 11 | enableSystemTray: true, |
12 | minimizeToSystemTray: false, | 12 | minimizeToSystemTray: false, |
13 | showDisabledServices: true, | 13 | showDisabledServices: true, |
14 | showMessageBadgeWhenMuted: true, | ||
14 | enableSpellchecking: true, | 15 | enableSpellchecking: true, |
15 | // spellcheckingLanguage: 'auto', | 16 | // spellcheckingLanguage: 'auto', |
16 | locale: 'en-US', | 17 | locale: 'en-US', |
diff --git a/src/containers/layout/AppLayoutContainer.js b/src/containers/layout/AppLayoutContainer.js index 7c6ceccd6..e4a9d60c3 100644 --- a/src/containers/layout/AppLayoutContainer.js +++ b/src/containers/layout/AppLayoutContainer.js | |||
@@ -73,13 +73,11 @@ export default class AppLayoutContainer extends Component { | |||
73 | ); | 73 | ); |
74 | } | 74 | } |
75 | 75 | ||
76 | const isMuted = settings.all.isAppMuted || app.isSystemMuted; | ||
77 | |||
78 | const sidebar = ( | 76 | const sidebar = ( |
79 | <Sidebar | 77 | <Sidebar |
80 | services={services.allDisplayed} | 78 | services={services.allDisplayed} |
81 | setActive={setActive} | 79 | setActive={setActive} |
82 | isAppMuted={isMuted} | 80 | isAppMuted={settings.all.isAppMuted} |
83 | openSettings={openSettings} | 81 | openSettings={openSettings} |
84 | closeSettings={closeSettings} | 82 | closeSettings={closeSettings} |
85 | reorder={reorder} | 83 | reorder={reorder} |
@@ -89,6 +87,8 @@ export default class AppLayoutContainer extends Component { | |||
89 | deleteService={deleteService} | 87 | deleteService={deleteService} |
90 | updateService={updateService} | 88 | updateService={updateService} |
91 | toggleMuteApp={toggleMuteApp} | 89 | toggleMuteApp={toggleMuteApp} |
90 | showMessageBadgeWhenMutedSetting={settings.all.showMessageBadgeWhenMuted} | ||
91 | showMessageBadgesEvenWhenMuted={ui.showMessageBadgesEvenWhenMuted} | ||
92 | /> | 92 | /> |
93 | ); | 93 | ); |
94 | 94 | ||
@@ -99,7 +99,7 @@ export default class AppLayoutContainer extends Component { | |||
99 | setWebviewReference={setWebviewReference} | 99 | setWebviewReference={setWebviewReference} |
100 | openWindow={openWindow} | 100 | openWindow={openWindow} |
101 | reload={reload} | 101 | reload={reload} |
102 | isAppMuted={isMuted} | 102 | isAppMuted={settings.all.isAppMuted} |
103 | update={updateService} | 103 | update={updateService} |
104 | /> | 104 | /> |
105 | ); | 105 | ); |
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 62e255dab..45ded9e5c 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -43,6 +43,10 @@ const messages = defineMessages({ | |||
43 | id: 'settings.app.form.showDisabledServices', | 43 | id: 'settings.app.form.showDisabledServices', |
44 | defaultMessage: '!!!Display disabled services tabs', | 44 | defaultMessage: '!!!Display disabled services tabs', |
45 | }, | 45 | }, |
46 | showMessageBadgeWhenMuted: { | ||
47 | id: 'settings.app.form.showMessagesBadgesWhenMuted', | ||
48 | defaultMessage: '!!!Show unread message badge when notifications are disabled', | ||
49 | }, | ||
46 | enableSpellchecking: { | 50 | enableSpellchecking: { |
47 | id: 'settings.app.form.enableSpellchecking', | 51 | id: 'settings.app.form.enableSpellchecking', |
48 | defaultMessage: '!!!Enable spell checking', | 52 | defaultMessage: '!!!Enable spell checking', |
@@ -85,6 +89,7 @@ export default class EditSettingsScreen extends Component { | |||
85 | enableSystemTray: settingsData.enableSystemTray, | 89 | enableSystemTray: settingsData.enableSystemTray, |
86 | minimizeToSystemTray: settingsData.minimizeToSystemTray, | 90 | minimizeToSystemTray: settingsData.minimizeToSystemTray, |
87 | showDisabledServices: settingsData.showDisabledServices, | 91 | showDisabledServices: settingsData.showDisabledServices, |
92 | showMessageBadgeWhenMuted: settingsData.showMessageBadgeWhenMuted, | ||
88 | enableSpellchecking: settingsData.enableSpellchecking, | 93 | enableSpellchecking: settingsData.enableSpellchecking, |
89 | // spellcheckingLanguage: settingsData.spellcheckingLanguage, | 94 | // spellcheckingLanguage: settingsData.spellcheckingLanguage, |
90 | locale: settingsData.locale, | 95 | locale: settingsData.locale, |
@@ -154,6 +159,11 @@ export default class EditSettingsScreen extends Component { | |||
154 | value: settings.all.showDisabledServices, | 159 | value: settings.all.showDisabledServices, |
155 | default: DEFAULT_APP_SETTINGS.showDisabledServices, | 160 | default: DEFAULT_APP_SETTINGS.showDisabledServices, |
156 | }, | 161 | }, |
162 | showMessageBadgeWhenMuted: { | ||
163 | label: intl.formatMessage(messages.showMessageBadgeWhenMuted), | ||
164 | value: settings.all.showMessageBadgeWhenMuted, | ||
165 | default: DEFAULT_APP_SETTINGS.showMessageBadgeWhenMuted, | ||
166 | }, | ||
157 | enableSpellchecking: { | 167 | enableSpellchecking: { |
158 | label: intl.formatMessage(messages.enableSpellchecking), | 168 | label: intl.formatMessage(messages.enableSpellchecking), |
159 | value: settings.all.enableSpellchecking, | 169 | value: settings.all.enableSpellchecking, |
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index 308ec8432..380871668 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json | |||
@@ -62,8 +62,8 @@ | |||
62 | "infobar.requiredRequestsFailed": "Could not load services and user information", | 62 | "infobar.requiredRequestsFailed": "Could not load services and user information", |
63 | "sidebar.settings": "Settings", | 63 | "sidebar.settings": "Settings", |
64 | "sidebar.addNewService": "Add new service", | 64 | "sidebar.addNewService": "Add new service", |
65 | "sidebar.mute": "Disable audio", | 65 | "sidebar.muteApp": "Disable notifications & audio", |
66 | "sidebar.unmute": "Enable audio", | 66 | "sidebar.unmuteApp": "Enable notifications & audio", |
67 | "services.welcome": "Welcome to Franz", | 67 | "services.welcome": "Welcome to Franz", |
68 | "services.getStarted": "Get started", | 68 | "services.getStarted": "Get started", |
69 | "settings.account.headline": "Account", | 69 | "settings.account.headline": "Account", |
@@ -148,6 +148,7 @@ | |||
148 | "settings.app.form.language": "Language", | 148 | "settings.app.form.language": "Language", |
149 | "settings.app.form.enableSpellchecking": "Enable spell checking", | 149 | "settings.app.form.enableSpellchecking": "Enable spell checking", |
150 | "settings.app.form.showDisabledServices": "Display disabled services tabs", | 150 | "settings.app.form.showDisabledServices": "Display disabled services tabs", |
151 | "settings.app.form.showMessagesBadgesWhenMuted": "Show unread message badge when notifications are disabled", | ||
151 | "settings.app.form.beta": "Include beta versions", | 152 | "settings.app.form.beta": "Include beta versions", |
152 | "settings.app.translationHelp": "Help us to translate Franz into your language.", | 153 | "settings.app.translationHelp": "Help us to translate Franz into your language.", |
153 | "settings.app.currentVersion": "Current version:", | 154 | "settings.app.currentVersion": "Current version:", |
diff --git a/src/models/Settings.js b/src/models/Settings.js index 3b352f9aa..35bfe0d05 100644 --- a/src/models/Settings.js +++ b/src/models/Settings.js | |||
@@ -8,6 +8,7 @@ export default class Settings { | |||
8 | @observable enableSystemTray = DEFAULT_APP_SETTINGS.enableSystemTray; | 8 | @observable enableSystemTray = DEFAULT_APP_SETTINGS.enableSystemTray; |
9 | @observable minimizeToSystemTray = DEFAULT_APP_SETTINGS.minimizeToSystemTray; | 9 | @observable minimizeToSystemTray = DEFAULT_APP_SETTINGS.minimizeToSystemTray; |
10 | @observable showDisabledServices = DEFAULT_APP_SETTINGS.showDisabledServices; | 10 | @observable showDisabledServices = DEFAULT_APP_SETTINGS.showDisabledServices; |
11 | @observable showMessageBadgeWhenMuted = DEFAULT_APP_SETTINGS.showMessageBadgeWhenMuted; | ||
11 | @observable enableSpellchecking = DEFAULT_APP_SETTINGS.enableSpellchecking; | 12 | @observable enableSpellchecking = DEFAULT_APP_SETTINGS.enableSpellchecking; |
12 | @observable locale = DEFAULT_APP_SETTINGS.locale; | 13 | @observable locale = DEFAULT_APP_SETTINGS.locale; |
13 | @observable beta = DEFAULT_APP_SETTINGS.beta; | 14 | @observable beta = DEFAULT_APP_SETTINGS.beta; |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 0b7c60bce..6125a7cff 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -45,7 +45,7 @@ export default class AppStore extends Store { | |||
45 | miner = null; | 45 | miner = null; |
46 | @observable minerHashrate = 0.0; | 46 | @observable minerHashrate = 0.0; |
47 | 47 | ||
48 | @observable isSystemMuted = false; | 48 | @observable isSystemMuteOverridden = false; |
49 | 49 | ||
50 | constructor(...args) { | 50 | constructor(...args) { |
51 | super(...args); | 51 | super(...args); |
@@ -67,6 +67,7 @@ export default class AppStore extends Store { | |||
67 | this._setLocale.bind(this), | 67 | this._setLocale.bind(this), |
68 | this._handleMiner.bind(this), | 68 | this._handleMiner.bind(this), |
69 | this._handleMinerThrottle.bind(this), | 69 | this._handleMinerThrottle.bind(this), |
70 | this._muteAppHandler.bind(this), | ||
70 | ]); | 71 | ]); |
71 | } | 72 | } |
72 | 73 | ||
@@ -150,6 +151,8 @@ export default class AppStore extends Store { | |||
150 | 151 | ||
151 | // Actions | 152 | // Actions |
152 | @action _notify({ title, options, notificationId, serviceId = null }) { | 153 | @action _notify({ title, options, notificationId, serviceId = null }) { |
154 | if (this.stores.settings.all.isAppMuted) return; | ||
155 | |||
153 | const notification = new window.Notification(title, options); | 156 | const notification = new window.Notification(title, options); |
154 | notification.onclick = (e) => { | 157 | notification.onclick = (e) => { |
155 | if (serviceId) { | 158 | if (serviceId) { |
@@ -217,7 +220,9 @@ export default class AppStore extends Store { | |||
217 | this.healthCheckRequest.execute(); | 220 | this.healthCheckRequest.execute(); |
218 | } | 221 | } |
219 | 222 | ||
220 | @action _muteApp({ isMuted }) { | 223 | @action _muteApp({ isMuted, overrideSystemMute = true }) { |
224 | this.isSystemMuteOverriden = overrideSystemMute; | ||
225 | |||
221 | this.actions.settings.update({ | 226 | this.actions.settings.update({ |
222 | settings: { | 227 | settings: { |
223 | isAppMuted: isMuted, | 228 | isAppMuted: isMuted, |
@@ -296,6 +301,14 @@ export default class AppStore extends Store { | |||
296 | } | 301 | } |
297 | } | 302 | } |
298 | 303 | ||
304 | _muteAppHandler() { | ||
305 | const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted; | ||
306 | |||
307 | if (!showMessageBadgesEvenWhenMuted) { | ||
308 | this.actions.app.setBadge({ unreadDirectMessageCount: 0, unreadIndirectMessageCount: 0 }); | ||
309 | } | ||
310 | } | ||
311 | |||
299 | // Helpers | 312 | // Helpers |
300 | async _appStartsCounter() { | 313 | async _appStartsCounter() { |
301 | // we need to wait until the settings request is resolved | 314 | // we need to wait until the settings request is resolved |
@@ -326,6 +339,12 @@ export default class AppStore extends Store { | |||
326 | } | 339 | } |
327 | 340 | ||
328 | _systemDND() { | 341 | _systemDND() { |
329 | this.isSystemMuted = getDoNotDisturb(); | 342 | const dnd = getDoNotDisturb(); |
343 | if (dnd === this.stores.settings.all.isAppMuted || !this.isSystemMuteOverriden) { | ||
344 | this.actions.app.muteApp({ | ||
345 | isMuted: dnd, | ||
346 | overrideSystemMute: false, | ||
347 | }); | ||
348 | } | ||
330 | } | 349 | } |
331 | } | 350 | } |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 22c376c06..b04aafd78 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -488,19 +488,26 @@ export default class ServicesStore extends Store { | |||
488 | } | 488 | } |
489 | 489 | ||
490 | _getUnreadMessageCountReaction() { | 490 | _getUnreadMessageCountReaction() { |
491 | const showMessageBadgeWhenMuted = this.stores.settings.all.showMessageBadgeWhenMuted; | ||
492 | const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted; | ||
493 | |||
491 | const unreadDirectMessageCount = this.enabled | 494 | const unreadDirectMessageCount = this.enabled |
495 | .filter(s => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted) | ||
492 | .map(s => s.unreadDirectMessageCount) | 496 | .map(s => s.unreadDirectMessageCount) |
493 | .reduce((a, b) => a + b, 0); | 497 | .reduce((a, b) => a + b, 0); |
494 | 498 | ||
495 | const unreadIndirectMessageCount = this.enabled | 499 | const unreadIndirectMessageCount = this.enabled |
496 | .filter(s => s.isIndirectMessageBadgeEnabled) | 500 | .filter(s => (showMessageBadgeWhenMuted || s.isIndirectMessageBadgeEnabled) && showMessageBadgesEvenWhenMuted) |
497 | .map(s => s.unreadIndirectMessageCount) | 501 | .map(s => s.unreadIndirectMessageCount) |
498 | .reduce((a, b) => a + b, 0); | 502 | .reduce((a, b) => a + b, 0); |
499 | 503 | ||
500 | this.actions.app.setBadge({ | 504 | // We can't just block this earlier, otherwise the mobx reaction won't be aware of the vars to watch in some cases |
501 | unreadDirectMessageCount, | 505 | if (showMessageBadgesEvenWhenMuted) { |
502 | unreadIndirectMessageCount, | 506 | this.actions.app.setBadge({ |
503 | }); | 507 | unreadDirectMessageCount, |
508 | unreadIndirectMessageCount, | ||
509 | }); | ||
510 | } | ||
504 | } | 511 | } |
505 | 512 | ||
506 | _logoutReaction() { | 513 | _logoutReaction() { |
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 30058f41d..33473f16d 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -5,6 +5,7 @@ import Store from './lib/Store'; | |||
5 | import Request from './lib/Request'; | 5 | import Request from './lib/Request'; |
6 | import CachedRequest from './lib/CachedRequest'; | 6 | import CachedRequest from './lib/CachedRequest'; |
7 | import { gaEvent } from '../lib/analytics'; | 7 | import { gaEvent } from '../lib/analytics'; |
8 | import SettingsModel from '../models/Settings'; | ||
8 | 9 | ||
9 | export default class SettingsStore extends Store { | 10 | export default class SettingsStore extends Store { |
10 | @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings'); | 11 | @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings'); |
@@ -25,7 +26,7 @@ export default class SettingsStore extends Store { | |||
25 | } | 26 | } |
26 | 27 | ||
27 | @computed get all() { | 28 | @computed get all() { |
28 | return this.allSettingsRequest.result || {}; | 29 | return this.allSettingsRequest.result || new SettingsModel(); |
29 | } | 30 | } |
30 | 31 | ||
31 | @action async _update({ settings }) { | 32 | @action async _update({ settings }) { |
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js index cb45b88b5..5e9cc9ba7 100644 --- a/src/stores/UIStore.js +++ b/src/stores/UIStore.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import { action, observable } from 'mobx'; | 1 | import { action, observable, computed } from 'mobx'; |
2 | 2 | ||
3 | import Store from './lib/Store'; | 3 | import Store from './lib/Store'; |
4 | 4 | ||
@@ -14,6 +14,12 @@ export default class UIStore extends Store { | |||
14 | this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); | 14 | this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); |
15 | } | 15 | } |
16 | 16 | ||
17 | @computed get showMessageBadgesEvenWhenMuted() { | ||
18 | const settings = this.stores.settings.all; | ||
19 | |||
20 | return (settings.isAppMuted && settings.showMessageBadgeWhenMuted) || !settings.isAppMuted; | ||
21 | } | ||
22 | |||
17 | // Actions | 23 | // Actions |
18 | @action _openSettings({ path = '/settings' }) { | 24 | @action _openSettings({ path = '/settings' }) { |
19 | const settingsPath = path !== '/settings' ? `/settings/${path}` : path; | 25 | const settingsPath = path !== '/settings' ? `/settings/${path}` : path; |
diff --git a/src/styles/tabs.scss b/src/styles/tabs.scss index 3ffc53558..ac48aabd6 100644 --- a/src/styles/tabs.scss +++ b/src/styles/tabs.scss | |||
@@ -78,6 +78,26 @@ | |||
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | .tab-item__info-badge { | ||
82 | width: 17px; | ||
83 | height: 17px; | ||
84 | background: $theme-gray-light; | ||
85 | color: $theme-gray-lighter; | ||
86 | border-radius: 20px; | ||
87 | padding: 0px 5px; | ||
88 | font-size: 11px; | ||
89 | position: absolute; | ||
90 | right: 8px; | ||
91 | bottom: 8px; | ||
92 | display: flex; | ||
93 | justify-content: center; | ||
94 | align-items: center; | ||
95 | |||
96 | &.is-indirect { | ||
97 | padding-top: 0px; | ||
98 | } | ||
99 | } | ||
100 | |||
81 | &.is-reordering { | 101 | &.is-reordering { |
82 | z-index: 99999; | 102 | z-index: 99999; |
83 | } | 103 | } |