aboutsummaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/News.js8
-rw-r--r--src/models/Plan.js4
-rw-r--r--src/models/Recipe.js14
-rw-r--r--src/models/RecipePreview.js8
-rw-r--r--src/models/Service.js5
-rw-r--r--src/models/Settings.js34
-rw-r--r--src/models/User.js19
7 files changed, 51 insertions, 41 deletions
diff --git a/src/models/News.js b/src/models/News.js
index a96e6550f..caf1d70e5 100644
--- a/src/models/News.js
+++ b/src/models/News.js
@@ -1,10 +1,10 @@
1// @flow 1// @flow
2 2
3export default class News { 3export default class News {
4 id: string = ''; 4 id = '';
5 message: string = ''; 5 message = '';
6 type: string = 'primary'; 6 type = 'primary';
7 sticky: bool = false; 7 sticky = false;
8 8
9 constructor(data) { 9 constructor(data) {
10 if (!data.id) { 10 if (!data.id) {
diff --git a/src/models/Plan.js b/src/models/Plan.js
index e77353824..c7b4a0962 100644
--- a/src/models/Plan.js
+++ b/src/models/Plan.js
@@ -1,11 +1,11 @@
1// @flow 1// @flow
2 2
3export default class Plan { 3export default class Plan {
4 month: { 4 month = {
5 id: '', 5 id: '',
6 price: 0, 6 price: 0,
7 } 7 }
8 year: { 8 year = {
9 id: '', 9 id: '',
10 price: 0, 10 price: 0,
11 } 11 }
diff --git a/src/models/Recipe.js b/src/models/Recipe.js
index 1fc23ac89..43c44514c 100644
--- a/src/models/Recipe.js
+++ b/src/models/Recipe.js
@@ -1,5 +1,7 @@
1import emailParser from 'address-rfc2822'; 1import emailParser from 'address-rfc2822';
2import semver from 'semver'; 2import semver from 'semver';
3import fs from 'fs-extra';
4import path from 'path';
3 5
4export default class Recipe { 6export default class Recipe {
5 id = ''; 7 id = '';
@@ -32,8 +34,12 @@ export default class Recipe {
32 throw Error(`Recipe '${data.name}' requires Id`); 34 throw Error(`Recipe '${data.name}' requires Id`);
33 } 35 }
34 36
35 if (!semver.valid(data.version)) { 37 try {
36 throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`); 38 if (!semver.valid(data.version)) {
39 throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
40 }
41 } catch (e) {
42 console.warn(e.message);
37 } 43 }
38 44
39 this.id = data.id || this.id; 45 this.id = data.id || this.id;
@@ -69,4 +75,8 @@ export default class Recipe {
69 75
70 return []; 76 return [];
71 } 77 }
78
79 get hasDarkMode() {
80 return fs.pathExistsSync(path.join(this.path, 'darkmode.css'));
81 }
72} 82}
diff --git a/src/models/RecipePreview.js b/src/models/RecipePreview.js
index 525a5c4b5..7470d757a 100644
--- a/src/models/RecipePreview.js
+++ b/src/models/RecipePreview.js
@@ -1,10 +1,10 @@
1// @flow 1// @flow
2 2
3export default class RecipePreview { 3export default class RecipePreview {
4 id: string = ''; 4 id = '';
5 name: string = ''; 5 name = '';
6 icon: string = ''; // TODO: check if this isn't replaced by `icons` 6 icon = ''; // TODO: check if this isn't replaced by `icons`
7 featured: bool = false; 7 featured = false;
8 8
9 constructor(data) { 9 constructor(data) {
10 if (!data.id) { 10 if (!data.id) {
diff --git a/src/models/Service.js b/src/models/Service.js
index bafb3f564..1bab8bd68 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -7,7 +7,7 @@ export default class Service {
7 recipe = ''; 7 recipe = '';
8 webview = null; 8 webview = null;
9 timer = null; 9 timer = null;
10 events: {}; 10 events = {};
11 11
12 isAttached = false; 12 isAttached = false;
13 13
@@ -28,6 +28,7 @@ export default class Service {
28 @observable iconUrl = ''; 28 @observable iconUrl = '';
29 @observable hasCustomUploadedIcon = false; 29 @observable hasCustomUploadedIcon = false;
30 @observable hasCrashed = false; 30 @observable hasCrashed = false;
31 @observable isDarkModeEnabled = false;
31 32
32 constructor(data, recipe) { 33 constructor(data, recipe) {
33 if (!data) { 34 if (!data) {
@@ -64,6 +65,8 @@ export default class Service {
64 65
65 this.isMuted = data.isMuted !== undefined ? data.isMuted : this.isMuted; 66 this.isMuted = data.isMuted !== undefined ? data.isMuted : this.isMuted;
66 67
68 this.isDarkModeEnabled = data.isDarkModeEnabled !== undefined ? data.isDarkModeEnabled : this.isDarkModeEnabled;
69
67 this.hasCustomUploadedIcon = data.hasCustomIcon !== undefined ? data.hasCustomIcon : this.hasCustomUploadedIcon; 70 this.hasCustomUploadedIcon = data.hasCustomIcon !== undefined ? data.hasCustomIcon : this.hasCustomUploadedIcon;
68 71
69 this.recipe = recipe; 72 this.recipe = recipe;
diff --git a/src/models/Settings.js b/src/models/Settings.js
index e39b63087..0e4c59057 100644
--- a/src/models/Settings.js
+++ b/src/models/Settings.js
@@ -2,19 +2,29 @@ import { observable, extendObservable } from 'mobx';
2import { DEFAULT_APP_SETTINGS } from '../config'; 2import { DEFAULT_APP_SETTINGS } from '../config';
3 3
4export default class Settings { 4export default class Settings {
5 @observable autoLaunchInBackground = DEFAULT_APP_SETTINGS.autoLaunchInBackground; 5 @observable app = DEFAULT_APP_SETTINGS
6 @observable runInBackground = DEFAULT_APP_SETTINGS.runInBackground;
7 @observable enableSystemTray = DEFAULT_APP_SETTINGS.enableSystemTray;
8 @observable minimizeToSystemTray = DEFAULT_APP_SETTINGS.minimizeToSystemTray;
9 @observable showDisabledServices = DEFAULT_APP_SETTINGS.showDisabledServices;
10 @observable showMessageBadgeWhenMuted = DEFAULT_APP_SETTINGS.showMessageBadgeWhenMuted;
11 @observable enableSpellchecking = DEFAULT_APP_SETTINGS.enableSpellchecking;
12 @observable locale = DEFAULT_APP_SETTINGS.locale;
13 @observable beta = DEFAULT_APP_SETTINGS.beta;
14 @observable isAppMuted = DEFAULT_APP_SETTINGS.isAppMuted;
15 6
16 constructor(data) { 7 @observable service = {
17 Object.assign(this, data); 8 activeService: '',
9 }
10
11 @observable group = {
12 collapsed: [],
13 disabled: [],
14 }
15
16 @observable stats = {
17 appStarts: 0,
18 }
19
20 @observable migration = {}
21
22 constructor({ app, service, group, stats, migration }) {
23 Object.assign(this.app, app);
24 Object.assign(this.service, service);
25 Object.assign(this.group, group);
26 Object.assign(this.stats, stats);
27 Object.assign(this.migration, migration);
18 } 28 }
19 29
20 update(data) { 30 update(data) {
diff --git a/src/models/User.js b/src/models/User.js
index 6fca78f90..3e4aa187d 100644
--- a/src/models/User.js
+++ b/src/models/User.js
@@ -1,4 +1,4 @@
1import { observable, computed } from 'mobx'; 1import { observable } from 'mobx';
2 2
3export default class User { 3export default class User {
4 id = null; 4 id = null;
@@ -15,14 +15,7 @@ export default class User {
15 @observable donor = {}; 15 @observable donor = {};
16 @observable isDonor = false; 16 @observable isDonor = false;
17 @observable isMiner = false; 17 @observable isMiner = false;
18 @observable isSSO = false; 18 @observable locale = false;
19 @observable company = {
20 name: 'Happle Apps',
21 contact: {
22 technical: 'technical@company.com',
23 default: 'default@company.com',
24 },
25 };
26 19
27 constructor(data) { 20 constructor(data) {
28 if (!data.id) { 21 if (!data.id) {
@@ -41,12 +34,6 @@ export default class User {
41 this.isDonor = data.isDonor || this.isDonor; 34 this.isDonor = data.isDonor || this.isDonor;
42 this.isSubscriptionOwner = data.isSubscriptionOwner || this.isSubscriptionOwner; 35 this.isSubscriptionOwner = data.isSubscriptionOwner || this.isSubscriptionOwner;
43 this.isMiner = data.isMiner || this.isMiner; 36 this.isMiner = data.isMiner || this.isMiner;
44 this.isSSO = data.isSSO || this.isSSO; 37 this.locale = data.locale || this.locale;
45 this.company = data.company || this.company;
46 }
47
48 @computed get isEnterprise() {
49 // return false
50 return this.company.name !== undefined;
51 } 38 }
52} 39}