diff options
author | muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com> | 2022-11-17 05:45:39 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-17 00:15:39 +0000 |
commit | d9502c7516bc2d4ae467c6ea8a2e4816b0885f37 (patch) | |
tree | b339c587a5529ac26d52cfc12d9972a8a00255e6 /src/stores/GlobalErrorStore.ts | |
parent | Transform JSX components to TSX (#755) (diff) | |
download | ferdium-app-d9502c7516bc2d4ae467c6ea8a2e4816b0885f37.tar.gz ferdium-app-d9502c7516bc2d4ae467c6ea8a2e4816b0885f37.tar.zst ferdium-app-d9502c7516bc2d4ae467c6ea8a2e4816b0885f37.zip |
Transfrom workspace components to ts (#775)
Diffstat (limited to 'src/stores/GlobalErrorStore.ts')
-rw-r--r-- | src/stores/GlobalErrorStore.ts | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/stores/GlobalErrorStore.ts b/src/stores/GlobalErrorStore.ts index c42e9a4af..be86563d0 100644 --- a/src/stores/GlobalErrorStore.ts +++ b/src/stores/GlobalErrorStore.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { observable, action, makeObservable } from 'mobx'; | 1 | import { observable, action, makeObservable } from 'mobx'; |
2 | import { Response } from 'electron'; | ||
2 | import { Actions } from '../actions/lib/actions'; | 3 | import { Actions } from '../actions/lib/actions'; |
3 | import { ApiInterface } from '../api'; | 4 | import { ApiInterface } from '../api'; |
4 | import { Stores } from '../@types/stores.types'; | 5 | import { Stores } from '../@types/stores.types'; |
@@ -11,12 +12,8 @@ interface Message { | |||
11 | message?: string; | 12 | message?: string; |
12 | status?: number; | 13 | status?: number; |
13 | }; | 14 | }; |
14 | request?: { | 15 | request?: Request; |
15 | result: any; | 16 | response?: Response; |
16 | wasExecuted: any; | ||
17 | method: any; | ||
18 | }; | ||
19 | response?: any; | ||
20 | server?: any; | 17 | server?: any; |
21 | info?: any; | 18 | info?: any; |
22 | url?: string; | 19 | url?: string; |
@@ -28,7 +25,7 @@ export default class GlobalErrorStore extends TypedStore { | |||
28 | 25 | ||
29 | @observable messages: Message[] = []; | 26 | @observable messages: Message[] = []; |
30 | 27 | ||
31 | @observable response: object = {}; | 28 | @observable response: Response = {} as Response; |
32 | 29 | ||
33 | // TODO: Get rid of the @ts-ignores in this function. | 30 | // TODO: Get rid of the @ts-ignores in this function. |
34 | constructor(stores: Stores, api: ApiInterface, actions: Actions) { | 31 | constructor(stores: Stores, api: ApiInterface, actions: Actions) { |
@@ -85,21 +82,15 @@ export default class GlobalErrorStore extends TypedStore { | |||
85 | } | 82 | } |
86 | } | 83 | } |
87 | 84 | ||
88 | @action _handleRequests = async (request: { | 85 | @action _handleRequests = async (request: Request): Promise<void> => { |
89 | isError: any; | ||
90 | error: { json: () => object | PromiseLike<object> }; | ||
91 | result: any; | ||
92 | wasExecuted: any; | ||
93 | _method: any; | ||
94 | }): Promise<void> => { | ||
95 | if (request.isError) { | 86 | if (request.isError) { |
96 | this.error = request.error; | 87 | this.error = request.error; |
97 | 88 | ||
98 | if (request.error.json) { | 89 | if (request.error && request.error.json) { |
99 | try { | 90 | try { |
100 | this.response = await request.error.json(); | 91 | this.response = await request.error.json(); |
101 | } catch { | 92 | } catch { |
102 | this.response = {}; | 93 | this.response = {} as Response; |
103 | } | 94 | } |
104 | if (this.error?.status === 401) { | 95 | if (this.error?.status === 401) { |
105 | window['ferdium'].stores.app.authRequestFailed = true; | 96 | window['ferdium'].stores.app.authRequestFailed = true; |
@@ -111,8 +102,8 @@ export default class GlobalErrorStore extends TypedStore { | |||
111 | request: { | 102 | request: { |
112 | result: request.result, | 103 | result: request.result, |
113 | wasExecuted: request.wasExecuted, | 104 | wasExecuted: request.wasExecuted, |
114 | method: request._method, | 105 | method: request.method, |
115 | }, | 106 | } as Request, |
116 | error: this.error, | 107 | error: this.error, |
117 | response: this.response, | 108 | response: this.response, |
118 | server: window['ferdium'].stores.settings.app.server, | 109 | server: window['ferdium'].stores.settings.app.server, |