-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Last Active Rubric Name to local storage
- Loading branch information
Showing
5 changed files
with
46 additions
and
37 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
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,21 @@ | ||
import { Rubric } from "../types/rubric"; | ||
import * as LocalStorage from "../services/localStorage"; | ||
import * as IndexedDb from "../services/indexedDbService"; | ||
|
||
export async function getLastActiveRubricAsync(): Promise<Rubric | undefined> { | ||
const lastActiveRubricName = LocalStorage.getLastActiveRubricName(); | ||
return await IndexedDb.getRubricFromIndexedDbAsync(lastActiveRubricName); | ||
} | ||
|
||
export async function saveRubricAsync(rubric: Rubric) { | ||
await IndexedDb.saveRubricToIndexedDbAsync(rubric); | ||
LocalStorage.setLastActiveRubricName(rubric.name); | ||
} | ||
|
||
export async function deleteRubricAsync(name: string) { | ||
await IndexedDb.deleteRubricFromIndexedDbAsync(name); | ||
|
||
if (LocalStorage.getLastActiveRubricName() === name) { | ||
LocalStorage.setLastActiveRubricName(""); | ||
} | ||
} |