-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #595 from enkryptcom/feat/new-update-ui
Feat/new update UI
- Loading branch information
Showing
15 changed files
with
752 additions
and
5 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
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,62 @@ | ||
import BrowserStorage from '../common/browser-storage'; | ||
import { InternalStorageNamespace } from '@/types/provider'; | ||
import { IState, StorageKeys } from './types'; | ||
|
||
class UpdatesState { | ||
private storage: BrowserStorage; | ||
|
||
constructor() { | ||
this.storage = new BrowserStorage(InternalStorageNamespace.updatesState); | ||
} | ||
|
||
async setState(state: IState): Promise<void> { | ||
return this.storage.set(StorageKeys.updatesInfo, state); | ||
} | ||
|
||
async getState(): Promise<IState> { | ||
const state = this.storage.get(StorageKeys.updatesInfo); | ||
if (!state) { | ||
const newState: IState = { | ||
lastVersionViewed: '', | ||
currentRelease: '', | ||
currentReleaseTimestamp: 0, | ||
} | ||
return newState | ||
} | ||
return state; | ||
} | ||
|
||
async getLastVersionViewed(): Promise<IState['lastVersionViewed']> { | ||
const state: IState = await this.getState(); | ||
return state?.lastVersionViewed ?? ''; | ||
} | ||
async setLastVersionViewed(lastVersionViewed: string): Promise<void> { | ||
const state: IState = await this.getState(); | ||
const newState: IState = { ...state, lastVersionViewed } | ||
await this.setState(newState); | ||
} | ||
|
||
async getCurrentRelease(): Promise<IState['currentRelease']> { | ||
const state: IState = await this.getState(); | ||
return state?.currentRelease ?? ''; | ||
} | ||
|
||
async setCurrentRelease(currentRelease: string): Promise<void> { | ||
const state: IState = await this.getState(); | ||
const newState: IState = { ...state, currentRelease } | ||
await this.setState(newState); | ||
} | ||
|
||
async getCurrentReleaseTimestamp(): Promise<IState['currentReleaseTimestamp']> { | ||
const state: IState = await this.getState(); | ||
return state?.currentReleaseTimestamp ?? 0; | ||
} | ||
|
||
async setCurrentReleaseTimestamp(currentReleaseTimestamp: number): Promise<void> { | ||
const state: IState = await this.getState(); | ||
const newState: IState = { ...state, currentReleaseTimestamp } | ||
await this.setState(newState); | ||
} | ||
} | ||
|
||
export default UpdatesState; |
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,9 @@ | ||
export enum StorageKeys { | ||
updatesInfo = 'updates-info', | ||
} | ||
|
||
export interface IState { | ||
lastVersionViewed: string; | ||
currentRelease: string; | ||
currentReleaseTimestamp: number; | ||
} |
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
Oops, something went wrong.