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) --- src/models/Recipe.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/models/Recipe.ts') 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 -- cgit v1.2.3-54-g00ecf