dismiss & use svelte in client

This commit is contained in:
2021-11-23 14:12:38 +01:00
parent a4e0bf1532
commit 4c0a60b14a
11 changed files with 171 additions and 81 deletions

View File

@@ -4,6 +4,7 @@ import dayjs from 'dayjs'
import { dashboard } from '../shared/utils'
import { insertLog, normalizeTimestamp, DB } from '../shared/db'
import { getSettingsWithDefaults, getUsageForHost, percentagesToBool } from '../shared/lib'
import { DismissValidator, checkForErrors } from '../shared/validation'
browser.browserAction.onClicked.addListener(() => browser.tabs.create({ url: dashboard, active: true }))
@@ -65,5 +66,13 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
case 'report':
DB.settings.put({ key: 'lastActivity', value: new Date() })
break
case 'dismiss':
const entry = {
host: message.host,
timestamp: new Date(),
duration: message.duration,
}
if (!checkForErrors(DismissValidator, entry)) DB.dismiss.put(entry)
break
}
})