aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos
diff options
context:
space:
mode:
authorLibravatar Muhamed <unknown>2022-11-24 02:56:10 +0530
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-11-25 05:04:25 +0530
commitf92933c396db9e94ffd297c41add86de88dfc6c6 (patch)
tree57789f7f64c618086c3792833d076244d879aa75 /src/features/todos
parentfix: use 'Route' from 'react-router-dom' package (diff)
downloadferdium-app-f92933c396db9e94ffd297c41add86de88dfc6c6.tar.gz
ferdium-app-f92933c396db9e94ffd297c41add86de88dfc6c6.tar.zst
ferdium-app-f92933c396db9e94ffd297c41add86de88dfc6c6.zip
chore: transform workspace action store and todo store into ts
Diffstat (limited to 'src/features/todos')
-rw-r--r--src/features/todos/store.ts (renamed from src/features/todos/store.js)40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/features/todos/store.js b/src/features/todos/store.ts
index 0f195f10d..5cf5e1d75 100644
--- a/src/features/todos/store.js
+++ b/src/features/todos/store.ts
@@ -1,5 +1,7 @@
1import { Webview } from 'react-electron-web-view';
1import { computed, action, observable, makeObservable } from 'mobx'; 2import { computed, action, observable, makeObservable } from 'mobx';
2import localStorage from 'mobx-localstorage'; 3import localStorage from 'mobx-localstorage';
4import { Actions } from '../../actions/lib/actions';
3 5
4import { ThemeType } from '../../themes'; 6import { ThemeType } from '../../themes';
5import { todoActions } from './actions'; 7import { todoActions } from './actions';
@@ -13,7 +15,7 @@ import {
13} from '../../config'; 15} from '../../config';
14import { isValidExternalURL } from '../../helpers/url-helpers'; 16import { isValidExternalURL } from '../../helpers/url-helpers';
15import FeatureStore from '../utils/FeatureStore'; 17import FeatureStore from '../utils/FeatureStore';
16import { createReactions } from '../../stores/lib/Reaction'; 18import Reaction, { createReactions } from '../../stores/lib/Reaction';
17import { createActionBindings } from '../utils/ActionBinding'; 19import { createActionBindings } from '../utils/ActionBinding';
18import { IPC, TODOS_ROUTES } from './constants'; 20import { IPC, TODOS_ROUTES } from './constants';
19import UserAgent from '../../models/UserAgent'; 21import UserAgent from '../../models/UserAgent';
@@ -23,16 +25,20 @@ const debug = require('../../preload-safe-debug')(
23); 25);
24 26
25export default class TodoStore extends FeatureStore { 27export default class TodoStore extends FeatureStore {
26 @observable stores = null; 28 @observable stores: any = null;
27 29
28 @observable isFeatureActive = false; 30 @observable isFeatureActive = false;
29 31
30 @observable webview = null; 32 @observable webview: Webview | undefined;
31 33
32 @observable userAgentModel = new UserAgent(); 34 @observable userAgentModel = new UserAgent();
33 35
34 isInitialized = false; 36 isInitialized = false;
35 37
38 actions: Actions | undefined;
39
40 _allReactions: Reaction[] | undefined;
41
36 constructor() { 42 constructor() {
37 super(); 43 super();
38 44
@@ -142,7 +148,7 @@ export default class TodoStore extends FeatureStore {
142 @action stop() { 148 @action stop() {
143 super.stop(); 149 super.stop();
144 debug('TodoStore::stop'); 150 debug('TodoStore::stop');
145 this.reset(); 151 // this.reset(); // TODO - [TECH DEBT][PROP NOT IN CLASS] check it later
146 this.isFeatureActive = false; 152 this.isFeatureActive = false;
147 } 153 }
148 154
@@ -184,7 +190,10 @@ export default class TodoStore extends FeatureStore {
184 } 190 }
185 }; 191 };
186 192
187 @action _handleClientMessage = ({ channel, message = {} }) => { 193 @action _handleClientMessage = ({
194 channel,
195 message = { action: '', data: { url: '', serviceId: '' } },
196 }) => {
188 debug('_handleClientMessage', channel, message); 197 debug('_handleClientMessage', channel, message);
189 switch (message.action) { 198 switch (message.action) {
190 case 'todos:initialized': 199 case 'todos:initialized':
@@ -195,7 +204,7 @@ export default class TodoStore extends FeatureStore {
195 break; 204 break;
196 default: 205 default:
197 debug('Other message received', channel, message); 206 debug('Other message received', channel, message);
198 if (this.stores.services.isTodosServiceAdded) { 207 if (this.stores.services.isTodosServiceAdded && this.actions) {
199 this.actions.service.handleIPCMessage({ 208 this.actions.service.handleIPCMessage({
200 serviceId: this.stores.services.isTodosServiceAdded.id, 209 serviceId: this.stores.services.isTodosServiceAdded.id,
201 channel, 210 channel,
@@ -206,6 +215,9 @@ export default class TodoStore extends FeatureStore {
206 }; 215 };
207 216
208 _handleNewWindowEvent = ({ url }) => { 217 _handleNewWindowEvent = ({ url }) => {
218 if (!this.actions) {
219 return;
220 }
209 this.actions.app.openExternalUrl({ url }); 221 this.actions.app.openExternalUrl({ url });
210 }; 222 };
211 223
@@ -222,15 +234,19 @@ export default class TodoStore extends FeatureStore {
222 _openDevTools = () => { 234 _openDevTools = () => {
223 debug('_openDevTools'); 235 debug('_openDevTools');
224 236
225 const webview = document.querySelector('#todos-panel webview'); 237 const webview = document.querySelector<Webview>('#todos-panel webview');
226 if (webview) webview.openDevTools(); 238 if (webview) {
239 webview.openDevTools();
240 }
227 }; 241 };
228 242
229 _reload = () => { 243 _reload = () => {
230 debug('_reload'); 244 debug('_reload');
231 245
232 const webview = document.querySelector('#todos-panel webview'); 246 const webview = document.querySelector<Webview>('#todos-panel webview');
233 if (webview) webview.reload(); 247 if (webview) {
248 webview.reload();
249 }
234 }; 250 };
235 251
236 // Todos client message handlers 252 // Todos client message handlers
@@ -260,7 +276,9 @@ export default class TodoStore extends FeatureStore {
260 if (url) { 276 if (url) {
261 this.stores.services.one(serviceId).webview.loadURL(url); 277 this.stores.services.one(serviceId).webview.loadURL(url);
262 } 278 }
263 this.actions.service.setActive({ serviceId }); 279 if (this.actions) {
280 this.actions.service.setActive({ serviceId });
281 }
264 }; 282 };
265 283
266 // Reactions 284 // Reactions