This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store): save preference of last opened styleguide and page
- Loading branch information
1 parent
3dbfef6
commit d833658
Showing
4 changed files
with
85 additions
and
7 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,37 @@ | ||
import { JsonObject } from './json'; | ||
import * as MobX from 'mobx'; | ||
|
||
export class Preferences { | ||
@MobX.observable private lastStyleguidePath?: string; | ||
@MobX.observable private lastPageId?: string; | ||
|
||
public static fromJsonObject(jsonObject: JsonObject): Preferences { | ||
const preferences: Preferences = new Preferences(); | ||
preferences.lastStyleguidePath = jsonObject.lastStyleguidePath as string; | ||
preferences.lastPageId = jsonObject.lastPageId as string; | ||
return preferences; | ||
} | ||
|
||
public getLastStyleguidePath(): string | undefined { | ||
return this.lastStyleguidePath; | ||
} | ||
|
||
public getLastPageId(): string | undefined { | ||
return this.lastPageId; | ||
} | ||
|
||
public setLastStyleguidePath(lastStyleguidePath?: string): void { | ||
this.lastStyleguidePath = lastStyleguidePath; | ||
} | ||
|
||
public setLastPageId(lastPageId?: string): void { | ||
this.lastPageId = lastPageId; | ||
} | ||
|
||
public toJsonObject(): JsonObject { | ||
return { | ||
lastStyleguidePath: this.getLastStyleguidePath(), | ||
lastPageId: this.getLastPageId() | ||
}; | ||
} | ||
} |