diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-12-24 22:11:36 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-12-24 22:11:36 +0100 |
commit | df44b69c4655415fe1e44689ece443ec06ef0f52 (patch) | |
tree | e677ed5f5328bb3b14bc976c7392d8e259f89034 /src/models | |
parent | [wip] add icon upload (diff) | |
parent | Merge pull request #494 from heavypackets/websecurity-enable-patch (diff) | |
download | ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.tar.gz ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.tar.zst ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.zip |
Merge branch 'develop' into feature/icon-upload
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/News.js | 2 | ||||
-rw-r--r-- | src/models/Plan.js | 2 | ||||
-rw-r--r-- | src/models/Recipe.js | 9 | ||||
-rw-r--r-- | src/models/RecipePreview.js | 2 | ||||
-rw-r--r-- | src/models/Service.js | 17 | ||||
-rw-r--r-- | src/models/Settings.js | 24 | ||||
-rw-r--r-- | src/models/User.js | 2 |
7 files changed, 51 insertions, 7 deletions
diff --git a/src/models/News.js b/src/models/News.js index e8953ff8c..a96e6550f 100644 --- a/src/models/News.js +++ b/src/models/News.js | |||
@@ -6,7 +6,7 @@ export default class News { | |||
6 | type: string = 'primary'; | 6 | type: string = 'primary'; |
7 | sticky: bool = false; | 7 | sticky: bool = false; |
8 | 8 | ||
9 | constructor(data: Object) { | 9 | constructor(data) { |
10 | if (!data.id) { | 10 | if (!data.id) { |
11 | throw Error('News requires Id'); | 11 | throw Error('News requires Id'); |
12 | } | 12 | } |
diff --git a/src/models/Plan.js b/src/models/Plan.js index 1f2a44902..e77353824 100644 --- a/src/models/Plan.js +++ b/src/models/Plan.js | |||
@@ -10,7 +10,7 @@ export default class Plan { | |||
10 | price: 0, | 10 | price: 0, |
11 | } | 11 | } |
12 | 12 | ||
13 | constructor(data: Object) { | 13 | constructor(data) { |
14 | Object.assign(this, data); | 14 | Object.assign(this, data); |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/src/models/Recipe.js b/src/models/Recipe.js index 9971df77c..1fc23ac89 100644 --- a/src/models/Recipe.js +++ b/src/models/Recipe.js | |||
@@ -1,10 +1,11 @@ | |||
1 | import emailParser from 'address-rfc2822'; | 1 | import emailParser from 'address-rfc2822'; |
2 | import semver from 'semver'; | ||
2 | 3 | ||
3 | export default class Recipe { | 4 | export default class Recipe { |
4 | id = ''; | 5 | id = ''; |
5 | name = ''; | 6 | name = ''; |
6 | description = ''; | 7 | description = ''; |
7 | version = '1.0'; | 8 | version = ''; |
8 | path = ''; | 9 | path = ''; |
9 | 10 | ||
10 | serviceURL = ''; | 11 | serviceURL = ''; |
@@ -15,6 +16,7 @@ export default class Recipe { | |||
15 | hasTeamId = false; | 16 | hasTeamId = false; |
16 | hasPredefinedUrl = false; | 17 | hasPredefinedUrl = false; |
17 | hasCustomUrl = false; | 18 | hasCustomUrl = false; |
19 | hasHostedOption = false; | ||
18 | urlInputPrefix = ''; | 20 | urlInputPrefix = ''; |
19 | urlInputSuffix = ''; | 21 | urlInputSuffix = ''; |
20 | 22 | ||
@@ -30,6 +32,10 @@ export default class Recipe { | |||
30 | throw Error(`Recipe '${data.name}' requires Id`); | 32 | throw Error(`Recipe '${data.name}' requires Id`); |
31 | } | 33 | } |
32 | 34 | ||
35 | if (!semver.valid(data.version)) { | ||
36 | throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`); | ||
37 | } | ||
38 | |||
33 | this.id = data.id || this.id; | 39 | this.id = data.id || this.id; |
34 | this.name = data.name || this.name; | 40 | this.name = data.name || this.name; |
35 | this.rawAuthor = data.author || this.author; | 41 | this.rawAuthor = data.author || this.author; |
@@ -45,6 +51,7 @@ export default class Recipe { | |||
45 | this.hasTeamId = data.config.hasTeamId || this.hasTeamId; | 51 | this.hasTeamId = data.config.hasTeamId || this.hasTeamId; |
46 | this.hasPredefinedUrl = data.config.hasPredefinedUrl || this.hasPredefinedUrl; | 52 | this.hasPredefinedUrl = data.config.hasPredefinedUrl || this.hasPredefinedUrl; |
47 | this.hasCustomUrl = data.config.hasCustomUrl || this.hasCustomUrl; | 53 | this.hasCustomUrl = data.config.hasCustomUrl || this.hasCustomUrl; |
54 | this.hasHostedOption = data.config.hasHostedOption || this.hasHostedOption; | ||
48 | 55 | ||
49 | this.urlInputPrefix = data.config.urlInputPrefix || this.urlInputPrefix; | 56 | this.urlInputPrefix = data.config.urlInputPrefix || this.urlInputPrefix; |
50 | this.urlInputSuffix = data.config.urlInputSuffix || this.urlInputSuffix; | 57 | this.urlInputSuffix = data.config.urlInputSuffix || this.urlInputSuffix; |
diff --git a/src/models/RecipePreview.js b/src/models/RecipePreview.js index 7b497edf3..525a5c4b5 100644 --- a/src/models/RecipePreview.js +++ b/src/models/RecipePreview.js | |||
@@ -6,7 +6,7 @@ export default class RecipePreview { | |||
6 | icon: string = ''; // TODO: check if this isn't replaced by `icons` | 6 | icon: string = ''; // TODO: check if this isn't replaced by `icons` |
7 | featured: bool = false; | 7 | featured: bool = false; |
8 | 8 | ||
9 | constructor(data: Object) { | 9 | constructor(data) { |
10 | if (!data.id) { | 10 | if (!data.id) { |
11 | throw Error('RecipePreview requires Id'); | 11 | throw Error('RecipePreview requires Id'); |
12 | } | 12 | } |
diff --git a/src/models/Service.js b/src/models/Service.js index eb68493fe..0b19440e7 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import { computed, observable } from 'mobx'; | 1 | import { computed, observable, autorun } from 'mobx'; |
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | import normalizeUrl from 'normalize-url'; | 3 | import normalizeUrl from 'normalize-url'; |
4 | 4 | ||
@@ -22,6 +22,7 @@ export default class Service { | |||
22 | @observable team = ''; | 22 | @observable team = ''; |
23 | @observable customUrl = ''; | 23 | @observable customUrl = ''; |
24 | @observable isNotificationEnabled = true; | 24 | @observable isNotificationEnabled = true; |
25 | @observable isBadgeEnabled = true; | ||
25 | @observable isIndirectMessageBadgeEnabled = true; | 26 | @observable isIndirectMessageBadgeEnabled = true; |
26 | @observable customIconUrl = ''; | 27 | @observable customIconUrl = ''; |
27 | @observable hasCrashed = false; | 28 | @observable hasCrashed = false; |
@@ -52,19 +53,31 @@ export default class Service { | |||
52 | this.isNotificationEnabled = data.isNotificationEnabled !== undefined | 53 | this.isNotificationEnabled = data.isNotificationEnabled !== undefined |
53 | ? data.isNotificationEnabled : this.isNotificationEnabled; | 54 | ? data.isNotificationEnabled : this.isNotificationEnabled; |
54 | 55 | ||
56 | this.isBadgeEnabled = data.isBadgeEnabled !== undefined | ||
57 | ? data.isBadgeEnabled : this.isBadgeEnabled; | ||
58 | |||
55 | this.isIndirectMessageBadgeEnabled = data.isIndirectMessageBadgeEnabled !== undefined | 59 | this.isIndirectMessageBadgeEnabled = data.isIndirectMessageBadgeEnabled !== undefined |
56 | ? data.isIndirectMessageBadgeEnabled : this.isIndirectMessageBadgeEnabled; | 60 | ? data.isIndirectMessageBadgeEnabled : this.isIndirectMessageBadgeEnabled; |
57 | 61 | ||
58 | this.isMuted = data.isMuted !== undefined ? data.isMuted : this.isMuted; | 62 | this.isMuted = data.isMuted !== undefined ? data.isMuted : this.isMuted; |
59 | 63 | ||
60 | this.recipe = recipe; | 64 | this.recipe = recipe; |
65 | |||
66 | autorun(() => { | ||
67 | if (!this.isEnabled) { | ||
68 | this.webview = null; | ||
69 | this.isAttached = false; | ||
70 | this.unreadDirectMessageCount = 0; | ||
71 | this.unreadIndirectMessageCount = 0; | ||
72 | } | ||
73 | }); | ||
61 | } | 74 | } |
62 | 75 | ||
63 | @computed get url() { | 76 | @computed get url() { |
64 | if (this.recipe.hasCustomUrl && this.customUrl) { | 77 | if (this.recipe.hasCustomUrl && this.customUrl) { |
65 | let url; | 78 | let url; |
66 | try { | 79 | try { |
67 | url = normalizeUrl(this.customUrl); | 80 | url = normalizeUrl(this.customUrl, { stripWWW: false }); |
68 | } catch (err) { | 81 | } catch (err) { |
69 | console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`); | 82 | console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`); |
70 | } | 83 | } |
diff --git a/src/models/Settings.js b/src/models/Settings.js new file mode 100644 index 000000000..ca44da258 --- /dev/null +++ b/src/models/Settings.js | |||
@@ -0,0 +1,24 @@ | |||
1 | import { observable, extendObservable } from 'mobx'; | ||
2 | import { DEFAULT_APP_SETTINGS } from '../config'; | ||
3 | |||
4 | export default class Settings { | ||
5 | @observable autoLaunchOnStart = DEFAULT_APP_SETTINGS.autoLaunchOnStart; | ||
6 | @observable autoLaunchInBackground = DEFAULT_APP_SETTINGS.autoLaunchInBackground; | ||
7 | @observable runInBackground = DEFAULT_APP_SETTINGS.runInBackground; | ||
8 | @observable enableSystemTray = DEFAULT_APP_SETTINGS.enableSystemTray; | ||
9 | @observable minimizeToSystemTray = DEFAULT_APP_SETTINGS.minimizeToSystemTray; | ||
10 | @observable showDisabledServices = DEFAULT_APP_SETTINGS.showDisabledServices; | ||
11 | @observable showMessageBadgeWhenMuted = DEFAULT_APP_SETTINGS.showMessageBadgeWhenMuted; | ||
12 | @observable enableSpellchecking = DEFAULT_APP_SETTINGS.enableSpellchecking; | ||
13 | @observable locale = DEFAULT_APP_SETTINGS.locale; | ||
14 | @observable beta = DEFAULT_APP_SETTINGS.beta; | ||
15 | @observable isAppMuted = DEFAULT_APP_SETTINGS.isAppMuted; | ||
16 | |||
17 | constructor(data) { | ||
18 | Object.assign(this, data); | ||
19 | } | ||
20 | |||
21 | update(data) { | ||
22 | extendObservable(this, data); | ||
23 | } | ||
24 | } | ||
diff --git a/src/models/User.js b/src/models/User.js index 94b579928..e2d2fc0c8 100644 --- a/src/models/User.js +++ b/src/models/User.js | |||
@@ -16,7 +16,7 @@ export default class User { | |||
16 | @observable isDonor = false; | 16 | @observable isDonor = false; |
17 | @observable isMiner = false; | 17 | @observable isMiner = false; |
18 | 18 | ||
19 | constructor(data: Object) { | 19 | constructor(data) { |
20 | if (!data.id) { | 20 | if (!data.id) { |
21 | throw Error('User requires Id'); | 21 | throw Error('User requires Id'); |
22 | } | 22 | } |