aboutsummaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-09-25 23:15:06 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-09-25 23:15:06 +0530
commit3e41ba42caba131d1556fe383225b83799953e0e (patch)
tree76a2e2d8cedc931cd56c263a3768c970bbe16473 /src/models
parentfix: fix issue with new API of 'du' npm module (diff)
downloadferdium-app-3e41ba42caba131d1556fe383225b83799953e0e.tar.gz
ferdium-app-3e41ba42caba131d1556fe383225b83799953e0e.tar.zst
ferdium-app-3e41ba42caba131d1556fe383225b83799953e0e.zip
refactor: extract constants; added TODO [skip ci]
Diffstat (limited to 'src/models')
-rw-r--r--src/models/Recipe.ts58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts
index 83d1d4478..859c75df0 100644
--- a/src/models/Recipe.ts
+++ b/src/models/Recipe.ts
@@ -30,8 +30,21 @@ interface IRecipe {
30 }; 30 };
31} 31}
32 32
33// Note: Do NOT change these default values. If they change, then the corresponding changes in the recipes needs to be done
34// TODO: Need to reconcile other properties
35const DEFAULT_RECIPE_SETTINGS = {
36 hasDirectMessages: true,
37 hasIndirectMessages: false,
38 hasNotificationSound: false,
39 hasTeamId: false,
40 hasCustomUrl: false,
41 hasHostedOption: false,
42 allowFavoritesDelineationInUnreadCount: false,
43 disablewebsecurity: false,
44 autoHibernate: false,
45};
46
33export default class Recipe { 47export default class Recipe {
34 // Note: Do NOT change these default values. If they change, then the corresponding changes in the recipes needs to be done
35 id: string = ''; 48 id: string = '';
36 49
37 name: string = ''; 50 name: string = '';
@@ -42,21 +55,19 @@ export default class Recipe {
42 55
43 aliases: string[] = []; 56 aliases: string[] = [];
44 57
45 path: string = '';
46
47 serviceURL: string = ''; 58 serviceURL: string = '';
48 59
49 hasDirectMessages: boolean = true; 60 hasDirectMessages: boolean = DEFAULT_RECIPE_SETTINGS.hasDirectMessages;
50 61
51 hasIndirectMessages: boolean = false; 62 hasIndirectMessages: boolean = DEFAULT_RECIPE_SETTINGS.hasIndirectMessages;
52 63
53 hasNotificationSound: boolean = false; 64 hasNotificationSound: boolean = DEFAULT_RECIPE_SETTINGS.hasNotificationSound;
54 65
55 hasTeamId: boolean = false; 66 hasTeamId: boolean = DEFAULT_RECIPE_SETTINGS.hasTeamId;
56 67
57 hasCustomUrl: boolean = false; 68 hasCustomUrl: boolean = DEFAULT_RECIPE_SETTINGS.hasCustomUrl;
58 69
59 hasHostedOption: boolean = false; 70 hasHostedOption: boolean = DEFAULT_RECIPE_SETTINGS.hasHostedOption;
60 71
61 urlInputPrefix: string = ''; 72 urlInputPrefix: string = '';
62 73
@@ -64,11 +75,14 @@ export default class Recipe {
64 75
65 message: string = ''; 76 message: string = '';
66 77
67 allowFavoritesDelineationInUnreadCount: boolean = false; 78 allowFavoritesDelineationInUnreadCount: boolean = DEFAULT_RECIPE_SETTINGS.allowFavoritesDelineationInUnreadCount;
68 79
69 disablewebsecurity: boolean = false; 80 disablewebsecurity: boolean = DEFAULT_RECIPE_SETTINGS.disablewebsecurity;
70 81
71 autoHibernate: boolean = false; 82 // TODO: Is this even used?
83 autoHibernate: boolean = DEFAULT_RECIPE_SETTINGS.autoHibernate;
84
85 path: string = '';
72 86
73 partition: string = ''; 87 partition: string = '';
74 88
@@ -87,32 +101,28 @@ export default class Recipe {
87 throw new Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`); 101 throw new Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
88 } 102 }
89 103
90 this.id = data.id || this.id; 104 // from the recipe
105 this.id = ifUndefinedString(data.id, this.id);
91 this.name = ifUndefinedString(data.name, this.name); 106 this.name = ifUndefinedString(data.name, this.name);
92 this.version = ifUndefinedString(data.version, this.version); 107 this.version = ifUndefinedString(data.version, this.version);
93 this.aliases = data.aliases || this.aliases; 108 this.aliases = data.aliases || this.aliases;
94 this.path = data.path;
95
96 this.serviceURL = ifUndefinedString(data.config.serviceURL, this.serviceURL); 109 this.serviceURL = ifUndefinedString(data.config.serviceURL, this.serviceURL);
97
98 this.hasDirectMessages = ifUndefinedBoolean(data.config.hasDirectMessages, this.hasDirectMessages); 110 this.hasDirectMessages = ifUndefinedBoolean(data.config.hasDirectMessages, this.hasDirectMessages);
99 this.hasIndirectMessages = ifUndefinedBoolean(data.config.hasIndirectMessages, this.hasIndirectMessages); 111 this.hasIndirectMessages = ifUndefinedBoolean(data.config.hasIndirectMessages, this.hasIndirectMessages);
100 this.hasNotificationSound = ifUndefinedBoolean(data.config.hasNotificationSound, this.hasNotificationSound); 112 this.hasNotificationSound = ifUndefinedBoolean(data.config.hasNotificationSound, this.hasNotificationSound);
101 this.hasTeamId = ifUndefinedBoolean(data.config.hasTeamId, this.hasTeamId); 113 this.hasTeamId = ifUndefinedBoolean(data.config.hasTeamId, this.hasTeamId);
102 this.hasCustomUrl = ifUndefinedBoolean(data.config.hasCustomUrl, this.hasCustomUrl); 114 this.hasCustomUrl = ifUndefinedBoolean(data.config.hasCustomUrl, this.hasCustomUrl);
103 this.hasHostedOption = ifUndefinedBoolean(data.config.hasHostedOption, this.hasHostedOption); 115 this.hasHostedOption = ifUndefinedBoolean(data.config.hasHostedOption, this.hasHostedOption);
104
105 this.urlInputPrefix = ifUndefinedString(data.config.urlInputPrefix, this.urlInputPrefix); 116 this.urlInputPrefix = ifUndefinedString(data.config.urlInputPrefix, this.urlInputPrefix);
106 this.urlInputSuffix = ifUndefinedString(data.config.urlInputSuffix, this.urlInputSuffix); 117 this.urlInputSuffix = ifUndefinedString(data.config.urlInputSuffix, this.urlInputSuffix);
107 118 this.disablewebsecurity = ifUndefinedBoolean(data.config.disablewebsecurity, this.disablewebsecurity);
108 this.disablewebsecurity = data.config.disablewebsecurity || this.disablewebsecurity; 119 this.autoHibernate = ifUndefinedBoolean(data.config.autoHibernate, this.autoHibernate);
109
110 this.autoHibernate = data.config.autoHibernate || this.autoHibernate;
111
112 this.partition = ifUndefinedString(data.config.partition, this.partition);
113
114 this.message = ifUndefinedString(data.config.message, this.message); 120 this.message = ifUndefinedString(data.config.message, this.message);
115 this.allowFavoritesDelineationInUnreadCount = ifUndefinedBoolean(data.config.allowFavoritesDelineationInUnreadCount, this.allowFavoritesDelineationInUnreadCount); 121 this.allowFavoritesDelineationInUnreadCount = ifUndefinedBoolean(data.config.allowFavoritesDelineationInUnreadCount, this.allowFavoritesDelineationInUnreadCount);
122
123 // computed
124 this.path = data.path;
125 this.partition = ifUndefinedString(data.config.partition, this.partition);
116 } 126 }
117 127
118 // TODO: Need to remove this if its not used anywhere 128 // TODO: Need to remove this if its not used anywhere