From 2e96a61955e525bf6269e41342bf3ffce05805a6 Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Fri, 24 Sep 2021 07:39:41 +0530 Subject: Allow services to delineate favorites vs non-favorites in unread counts (#1979) implements getferdi/recipes#721 (eg: office365-owa) --- CHANGELOG.md | 6 ++++ .../settings/services/EditServiceForm.js | 5 ++++ src/containers/settings/EditServiceScreen.js | 14 +++++++++ src/i18n/locales/en-US.json | 1 + src/models/Recipe.ts | 34 +++++++++++++--------- src/models/Service.js | 7 +++++ 6 files changed, 54 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26b94df53..0171c3b5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# [v5.6.3-nightly.12](https://github.com/getferdi/ferdi/compare/v5.6.3-nightly.10...v5.6.3-nightly.12) (2021-09-24) + +### Services + +- Update 'skype' and 'discord' to properly relinquish window object for image overlay 💖 @vraravam +- Allow services to delineate favorites vs non-favorites in unread counts (eg Outlook) (getferdi/recipes#721) 💖 @vraravam # [v5.6.3-nightly.10](https://github.com/getferdi/ferdi/compare/v5.6.3-nightly.9...v5.6.3-nightly.10) (2021-09-22) diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index 7df6d5c78..179741338 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js @@ -343,6 +343,11 @@ class EditServiceForm extends Component {

)} + {recipe.allowFavoritesDelineationInUnreadCount && ( + + )}
diff --git a/src/containers/settings/EditServiceScreen.js b/src/containers/settings/EditServiceScreen.js index e2ed4eeac..dee7e7cff 100644 --- a/src/containers/settings/EditServiceScreen.js +++ b/src/containers/settings/EditServiceScreen.js @@ -81,6 +81,10 @@ const messages = defineMessages({ id: 'settings.service.form.darkReaderSepia', defaultMessage: 'Dark Reader Sepia', }, + onlyShowFavoritesInUnreadCount: { + id: 'settings.service.form.onlyShowFavoritesInUnreadCount', + defaultMessage: 'Only show Favorites in unread count', + }, enableProxy: { id: 'settings.service.form.proxy.isEnabled', defaultMessage: 'Use Proxy', @@ -289,6 +293,16 @@ class EditServiceScreen extends Component { }); } + if (recipe.allowFavoritesDelineationInUnreadCount) { + Object.assign(config.fields, { + onlyShowFavoritesInUnreadCount: { + label: intl.formatMessage(messages.onlyShowFavoritesInUnreadCount), + value: service.onlyShowFavoritesInUnreadCount, + default: false, + }, + }); + } + if (proxy.isEnabled) { const serviceProxyConfig = stores.settings.proxy[service.id] || {}; diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index 25eedb456..471726ecc 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json @@ -321,6 +321,7 @@ "settings.service.form.isHibernatedEnabledInfo": "When enabled, a service will be shut down after a period of time to save system resources.", "settings.service.form.isMutedInfo": "When disabled, all notification sounds and audio playback are muted", "settings.service.form.name": "Name", + "settings.service.form.onlyShowFavoritesInUnreadCount": "Only show Favorites in unread count", "settings.service.form.openDarkmodeCss": "Open darkmode.css", "settings.service.form.openUserCss": "Open user.css", "settings.service.form.openUserJs": "Open user.js", diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts index 6022fb520..83d1d4478 100644 --- a/src/models/Recipe.ts +++ b/src/models/Recipe.ts @@ -1,6 +1,10 @@ import semver from 'semver'; import { pathExistsSync } from 'fs-extra'; import { join } from 'path'; +import { + ifUndefinedString, + ifUndefinedBoolean, +} from '../jsUtils'; interface IRecipe { id: string; @@ -22,6 +26,7 @@ interface IRecipe { autoHibernate?: boolean; partition?: string; message?: string; + allowFavoritesDelineationInUnreadCount?: boolean; }; } @@ -59,6 +64,8 @@ export default class Recipe { message: string = ''; + allowFavoritesDelineationInUnreadCount: boolean = false; + disablewebsecurity: boolean = false; autoHibernate: boolean = false; @@ -81,30 +88,31 @@ export default class Recipe { } this.id = data.id || this.id; - this.name = data.name || this.name; - this.version = data.version || this.version; + this.name = ifUndefinedString(data.name, this.name); + this.version = ifUndefinedString(data.version, this.version); this.aliases = data.aliases || this.aliases; this.path = data.path; - this.serviceURL = data.config.serviceURL || this.serviceURL; + this.serviceURL = ifUndefinedString(data.config.serviceURL, this.serviceURL); - this.hasDirectMessages = data.config.hasDirectMessages || this.hasDirectMessages; - this.hasIndirectMessages = data.config.hasIndirectMessages || this.hasIndirectMessages; - this.hasNotificationSound = data.config.hasNotificationSound || this.hasNotificationSound; - this.hasTeamId = data.config.hasTeamId || this.hasTeamId; - this.hasCustomUrl = data.config.hasCustomUrl || this.hasCustomUrl; - this.hasHostedOption = data.config.hasHostedOption || this.hasHostedOption; + this.hasDirectMessages = ifUndefinedBoolean(data.config.hasDirectMessages, this.hasDirectMessages); + this.hasIndirectMessages = ifUndefinedBoolean(data.config.hasIndirectMessages, this.hasIndirectMessages); + this.hasNotificationSound = ifUndefinedBoolean(data.config.hasNotificationSound, this.hasNotificationSound); + this.hasTeamId = ifUndefinedBoolean(data.config.hasTeamId, this.hasTeamId); + this.hasCustomUrl = ifUndefinedBoolean(data.config.hasCustomUrl, this.hasCustomUrl); + this.hasHostedOption = ifUndefinedBoolean(data.config.hasHostedOption, this.hasHostedOption); - this.urlInputPrefix = data.config.urlInputPrefix || this.urlInputPrefix; - this.urlInputSuffix = data.config.urlInputSuffix || this.urlInputSuffix; + this.urlInputPrefix = ifUndefinedString(data.config.urlInputPrefix, this.urlInputPrefix); + this.urlInputSuffix = ifUndefinedString(data.config.urlInputSuffix, this.urlInputSuffix); this.disablewebsecurity = data.config.disablewebsecurity || this.disablewebsecurity; this.autoHibernate = data.config.autoHibernate || this.autoHibernate; - this.partition = data.config.partition || this.partition; + this.partition = ifUndefinedString(data.config.partition, this.partition); - this.message = data.config.message || this.message; + this.message = ifUndefinedString(data.config.message, this.message); + this.allowFavoritesDelineationInUnreadCount = ifUndefinedBoolean(data.config.allowFavoritesDelineationInUnreadCount, this.allowFavoritesDelineationInUnreadCount); } // TODO: Need to remove this if its not used anywhere diff --git a/src/models/Service.js b/src/models/Service.js index cc001f98d..75dfde027 100644 --- a/src/models/Service.js +++ b/src/models/Service.js @@ -83,6 +83,8 @@ export default class Service { @observable isHibernationRequested = false; + @observable onlyShowFavoritesInUnreadCount = false; + @observable lastUsed = Date.now(); // timestamp @observable lastHibernated = null; // timestamp @@ -144,6 +146,10 @@ export default class Service { data.hasCustomIcon, this.hasCustomUploadedIcon, ); + this.onlyShowFavoritesInUnreadCount = ifUndefinedBoolean( + data.onlyShowFavoritesInUnreadCount, + this.onlyShowFavoritesInUnreadCount, + ); this.proxy = ifUndefinedString(data.proxy, this.proxy); this.spellcheckerLanguage = ifUndefinedString( data.spellcheckerLanguage, @@ -191,6 +197,7 @@ export default class Service { team: this.team, url: this.url, hasCustomIcon: this.hasCustomIcon, + onlyShowFavoritesInUnreadCount: this.onlyShowFavoritesInUnreadCount, }; } -- cgit v1.2.3-54-g00ecf