-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip quote generation if no-one has viewed the current quote
- Loading branch information
Showing
3 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import * as store from "$store"; | ||
|
||
export async function getQuote() { | ||
return await store.getItem<string>(["quote"]) ?? "Nothing to see here"; | ||
export async function getQuote(): Promise<string> { | ||
const quote = await store.getItem<string>(["quote"]) ?? "Nothing to see here"; | ||
await store.removeItem(["quote", "unseen"]); | ||
return quote; | ||
} | ||
|
||
export async function setQuote(quote: string) { | ||
await store.setItem(["quote"], quote); | ||
await store.setItem(["quote", "unseen"], true); | ||
} | ||
|
||
export async function isQuoteUnseen(): Promise<boolean> { | ||
return await store.getItem(["quote", "unseen"]) ?? false; | ||
} |