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)
---
.../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 +++++
5 files changed, 48 insertions(+), 13 deletions(-)
(limited to 'src')
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-70-g09d2