feat: recent activity card on Home and Retention card on Settings
This commit is contained in:
1 parent
35db442cd3
commit
43469ef08d
33 files changed
+2748
-204
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { t } from '@/i18n'
|
||||
import type { WorkspaceSettings } from '@/composables/useSettings'
|
||||
import { localDayTime } from '@/lib/activityTime'
|
||||
|
||||
export const FOREVER_DAYS = 0
|
||||
export const SAVED_VISIBLE_MS = 2000
|
||||
|
||||
const RANKED_PERIODS = [30, 90, 365, FOREVER_DAYS]
|
||||
|
||||
export function retentionOptions() {
|
||||
return RANKED_PERIODS.map((value) => ({ value, label: periodLabel(value) }))
|
||||
}
|
||||
|
||||
export function periodLabel(days: number) {
|
||||
switch (days) {
|
||||
case 30:
|
||||
return t('30 days')
|
||||
case 90:
|
||||
return t('90 days')
|
||||
case 365:
|
||||
return t('365 days')
|
||||
default:
|
||||
return t('Forever')
|
||||
}
|
||||
}
|
||||
|
||||
export function periodRank(days: number) {
|
||||
return RANKED_PERIODS.indexOf(days)
|
||||
}
|
||||
|
||||
export function isShorter(candidate: number, saved: number) {
|
||||
return periodRank(candidate) < periodRank(saved)
|
||||
}
|
||||
|
||||
export function helperCopy(days: number) {
|
||||
return days === FOREVER_DAYS
|
||||
? t('Nothing is removed automatically. The log grows over time.')
|
||||
: t('Older events are removed automatically.')
|
||||
}
|
||||
|
||||
export function lastCleanupLine(settings: WorkspaceSettings) {
|
||||
if (!settings.activity_last_cleanup_at) {
|
||||
return t('Never')
|
||||
}
|
||||
const removed = settings.activity_last_cleanup_removed
|
||||
const count = t(removed === 1 ? '{0} event removed' : '{0} events removed', [removed])
|
||||
return `${localDayTime(settings.activity_last_cleanup_at)} · ${count}`
|
||||
}
|
||||
|
||||
export function nextCleanupLine(settings: WorkspaceSettings) {
|
||||
return settings.activity_next_cleanup_at
|
||||
? localDayTime(settings.activity_next_cleanup_at)
|
||||
: t('Not scheduled')
|
||||
}
|
||||
|
||||
export function shorteningDescription(settings: WorkspaceSettings) {
|
||||
return settings.activity_next_cleanup_at
|
||||
? t("This happens at the next cleanup on {0}. It can't be undone.", [
|
||||
localDayTime(settings.activity_next_cleanup_at),
|
||||
])
|
||||
: t("Older events will be removed at the next cleanup. It can't be undone.")
|
||||
}
|
||||
Reference in new issue
Block a user