init
This commit is contained in:
commit
ec53fcbe95
1905 changed files with 513762 additions and 0 deletions
17
services/tips/tipHistory.ts
Normal file
17
services/tips/tipHistory.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js'
|
||||
|
||||
export function recordTipShown(tipId: string): void {
|
||||
const numStartups = getGlobalConfig().numStartups
|
||||
saveGlobalConfig(c => {
|
||||
const history = c.tipsHistory ?? {}
|
||||
if (history[tipId] === numStartups) return c
|
||||
return { ...c, tipsHistory: { ...history, [tipId]: numStartups } }
|
||||
})
|
||||
}
|
||||
|
||||
export function getSessionsSinceLastShown(tipId: string): number {
|
||||
const config = getGlobalConfig()
|
||||
const lastShown = config.tipsHistory?.[tipId]
|
||||
if (!lastShown) return Infinity
|
||||
return config.numStartups - lastShown
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue