-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auto-updates): no updates in platforms that don't support it
fix(auto-updates): no updates in platforms that don't support it
- Loading branch information
Showing
11 changed files
with
224 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import superagent from 'superagent'; | ||
|
||
import { ISystemState } from './SystemTypes'; | ||
|
||
export async function getSystem(): Promise<ISystemState> { | ||
return (await superagent.get(`/api/v1/system`)).body; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
import { | ||
SYSTEM_GET_SYSTEM_REQUEST, | ||
SYSTEM_GET_SYSTEM_ERROR, | ||
SYSTEM_GET_SYSTEM_SUCCESS | ||
} from './SystemTypes'; | ||
|
||
import * as API from './SystemAPI'; | ||
|
||
export function getSystem(): any { | ||
return async (dispatch: any) => { | ||
try { | ||
dispatch({ | ||
payload: {}, | ||
type: SYSTEM_GET_SYSTEM_REQUEST | ||
}); | ||
|
||
try { | ||
const system = await API.getSystem(); | ||
|
||
dispatch({ | ||
payload: system, | ||
type: SYSTEM_GET_SYSTEM_SUCCESS | ||
}); | ||
return system; | ||
} catch (error) { | ||
Sentry.captureException(error); | ||
|
||
dispatch({ | ||
payload: { error }, | ||
type: SYSTEM_GET_SYSTEM_ERROR | ||
}); | ||
} | ||
} catch (error) {} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
import { | ||
ISystemActionTypes, | ||
ISystemState, | ||
SYSTEM_GET_SYSTEM_SUCCESS | ||
} from './SystemTypes'; | ||
|
||
export const initialState: ISystemState = { | ||
platformSupportsUpdates: true | ||
}; | ||
|
||
export default function settingsReducer( | ||
state: ISystemState = initialState, | ||
action: ISystemActionTypes | ||
): ISystemState { | ||
try { | ||
switch (action.type) { | ||
case SYSTEM_GET_SYSTEM_SUCCESS: | ||
return action.payload; | ||
|
||
default: | ||
return state; | ||
} | ||
} catch (error) { | ||
Sentry.captureException(error); | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export interface IState { | ||
system: ISystemState; | ||
} | ||
|
||
export interface ISystemState { | ||
platformSupportsUpdates: boolean; | ||
} | ||
|
||
export const SYSTEM_GET_SYSTEM_REQUEST = 'SYSTEM_GET_SYSTEM_REQUEST'; | ||
export const SYSTEM_GET_SYSTEM_SUCCESS = 'SYSTEM_GET_SYSTEM_SUCCESS'; | ||
export const SYSTEM_GET_SYSTEM_ERROR = 'SYSTEM_GET_SYSTEM_ERROR'; | ||
|
||
export interface IGetSystemRequestAction { | ||
payload: {}; | ||
type: typeof SYSTEM_GET_SYSTEM_REQUEST; | ||
} | ||
|
||
export interface IGetSystemSuccessAction { | ||
payload: ISystemState; | ||
type: typeof SYSTEM_GET_SYSTEM_SUCCESS; | ||
} | ||
export interface IGetSystemErrorAction { | ||
payload: { | ||
error: string; | ||
}; | ||
type: typeof SYSTEM_GET_SYSTEM_ERROR; | ||
} | ||
|
||
export type ISystemActionTypes = | ||
| IGetSystemErrorAction | ||
| IGetSystemRequestAction | ||
| IGetSystemSuccessAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import express from 'express'; | ||
import * as Sentry from '@sentry/electron'; | ||
|
||
import { platformSupportsUpdates } from '../updater'; | ||
|
||
export default function (): express.Router { | ||
const router = express.Router(); | ||
|
||
router.get( | ||
`/`, | ||
async ( | ||
req: express.Request, | ||
res: express.Response, | ||
next: express.NextFunction | ||
) => { | ||
try { | ||
res.status(200).json({ | ||
platformSupportsUpdates: platformSupportsUpdates() | ||
}); | ||
} catch (error) { | ||
Sentry.captureException(error); | ||
res.status(500).json(error); | ||
} | ||
} | ||
); | ||
|
||
return router; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters