Browse Source

make cache mandatory for everyone.

imwald
Silberengel 3 weeks ago
parent
commit
a43208d834
  1. 18
      src/components/EventArchiveCacheSettings/index.tsx
  2. 2
      src/constants.ts
  3. 4
      src/i18n/locales/ar.ts
  4. 4
      src/i18n/locales/de.ts
  5. 4
      src/i18n/locales/en.ts
  6. 4
      src/i18n/locales/es.ts
  7. 4
      src/i18n/locales/fa.ts
  8. 4
      src/i18n/locales/fr.ts
  9. 4
      src/i18n/locales/hi.ts
  10. 4
      src/i18n/locales/it.ts
  11. 4
      src/i18n/locales/ja.ts
  12. 4
      src/i18n/locales/ko.ts
  13. 4
      src/i18n/locales/pl.ts
  14. 4
      src/i18n/locales/pt-BR.ts
  15. 4
      src/i18n/locales/pt-PT.ts
  16. 4
      src/i18n/locales/ru.ts
  17. 4
      src/i18n/locales/th.ts
  18. 4
      src/i18n/locales/zh.ts
  19. 26
      src/lib/event-archive-config.ts
  20. 11
      src/services/event-archive.service.ts

18
src/components/EventArchiveCacheSettings/index.tsx

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
import { Button } from '@/components/ui/button'
import { Label } from '@/components/ui/label'
import { Switch } from '@/components/ui/switch'
import { Input } from '@/components/ui/input'
import { StorageKey } from '@/constants'
import {
@ -22,7 +21,6 @@ function platformLabel(): string { @@ -22,7 +21,6 @@ function platformLabel(): string {
export default function EventArchiveCacheSettings() {
const { t } = useTranslation()
const [enabled, setEnabled] = useState(true)
const [maxMb, setMaxMb] = useState('')
const [maxEvents, setMaxEvents] = useState('')
const [sessionLru, setSessionLru] = useState('')
@ -51,14 +49,12 @@ export default function EventArchiveCacheSettings() { @@ -51,14 +49,12 @@ export default function EventArchiveCacheSettings() {
}, [t])
useEffect(() => {
setEnabled(window.localStorage.getItem(StorageKey.EVENT_ARCHIVE_ENABLED) !== 'false')
setMaxMb(window.localStorage.getItem(StorageKey.EVENT_ARCHIVE_MAX_MB) ?? '')
setMaxEvents(window.localStorage.getItem(StorageKey.EVENT_ARCHIVE_MAX_EVENTS) ?? '')
setSessionLru(window.localStorage.getItem(StorageKey.SESSION_EVENT_LRU_MAX) ?? '')
}, [])
const apply = useCallback(() => {
window.localStorage.setItem(StorageKey.EVENT_ARCHIVE_ENABLED, enabled ? 'true' : 'false')
const mb = maxMb.trim()
if (mb) window.localStorage.setItem(StorageKey.EVENT_ARCHIVE_MAX_MB, mb)
else window.localStorage.removeItem(StorageKey.EVENT_ARCHIVE_MAX_MB)
@ -71,7 +67,7 @@ export default function EventArchiveCacheSettings() { @@ -71,7 +67,7 @@ export default function EventArchiveCacheSettings() {
client.reapplySessionLruFromSettings()
invalidateArchiveFootprintCache()
toast.success(t('eventArchive.appliedToast'))
}, [enabled, maxMb, maxEvents, sessionLru, t])
}, [maxMb, maxEvents, sessionLru, t])
const effective = getEventArchiveConfig()
@ -81,17 +77,6 @@ export default function EventArchiveCacheSettings() { @@ -81,17 +77,6 @@ export default function EventArchiveCacheSettings() {
<p className="text-muted-foreground text-sm">{t('eventArchive.sectionBlurb')}</p>
<p className="text-muted-foreground text-xs">{defaultsHint}</p>
<div className="flex items-center justify-between gap-3">
<Label htmlFor="event-archive-enabled" className="text-sm font-normal">
{t('eventArchive.enablePersist')}
</Label>
<Switch
id="event-archive-enabled"
checked={enabled}
onCheckedChange={(v) => setEnabled(Boolean(v))}
/>
</div>
<div className="grid gap-3 sm:grid-cols-2">
<div className="space-y-1">
<Label htmlFor="archive-max-mb" className="text-sm font-normal">
@ -152,7 +137,6 @@ export default function EventArchiveCacheSettings() { @@ -152,7 +137,6 @@ export default function EventArchiveCacheSettings() {
<p className="text-muted-foreground text-xs">
{t('eventArchive.effectiveSummary', {
enabled: effective.enabled ? t('eventArchive.on') : t('eventArchive.off'),
mb: Math.round(effective.maxBytes / (1024 * 1024)),
events: effective.maxEvents,
lru: effective.sessionLruMax

2
src/constants.ts

@ -240,8 +240,6 @@ export const StorageKey = { @@ -240,8 +240,6 @@ export const StorageKey = {
SHOW_PUBLISH_SUCCESS_TOASTS: 'showPublishSuccessToasts',
/** When not `'false'`, show NIP-53 live activity banner (default on). */
SHOW_LIVE_ACTIVITIES_BANNER: 'showLiveActivitiesBanner',
/** Persist timeline notes/reactions to IndexedDB (platform defaults; disable for relay-only). */
EVENT_ARCHIVE_ENABLED: 'eventArchiveEnabled',
/** Max approximate archive size (MB). `0` in UI means “use platform default”. */
EVENT_ARCHIVE_MAX_MB: 'eventArchiveMaxMb',
/** Max rows in event archive. `0` means use platform default. */

4
src/i18n/locales/ar.ts

@ -631,7 +631,7 @@ export default { @@ -631,7 +631,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -643,7 +643,7 @@ export default { @@ -643,7 +643,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/de.ts

@ -667,7 +667,7 @@ export default { @@ -667,7 +667,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -679,7 +679,7 @@ export default { @@ -679,7 +679,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/en.ts

@ -660,7 +660,7 @@ export default { @@ -660,7 +660,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -672,7 +672,7 @@ export default { @@ -672,7 +672,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/es.ts

@ -636,7 +636,7 @@ export default { @@ -636,7 +636,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -648,7 +648,7 @@ export default { @@ -648,7 +648,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/fa.ts

@ -634,7 +634,7 @@ export default { @@ -634,7 +634,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -646,7 +646,7 @@ export default { @@ -646,7 +646,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/fr.ts

@ -635,7 +635,7 @@ export default { @@ -635,7 +635,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -647,7 +647,7 @@ export default { @@ -647,7 +647,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/hi.ts

@ -635,7 +635,7 @@ export default { @@ -635,7 +635,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -647,7 +647,7 @@ export default { @@ -647,7 +647,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/it.ts

@ -636,7 +636,7 @@ export default { @@ -636,7 +636,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -648,7 +648,7 @@ export default { @@ -648,7 +648,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/ja.ts

@ -632,7 +632,7 @@ export default { @@ -632,7 +632,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -644,7 +644,7 @@ export default { @@ -644,7 +644,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/ko.ts

@ -631,7 +631,7 @@ export default { @@ -631,7 +631,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -643,7 +643,7 @@ export default { @@ -643,7 +643,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/pl.ts

@ -633,7 +633,7 @@ export default { @@ -633,7 +633,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -645,7 +645,7 @@ export default { @@ -645,7 +645,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/pt-BR.ts

@ -635,7 +635,7 @@ export default { @@ -635,7 +635,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -647,7 +647,7 @@ export default { @@ -647,7 +647,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/pt-PT.ts

@ -635,7 +635,7 @@ export default { @@ -635,7 +635,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -647,7 +647,7 @@ export default { @@ -647,7 +647,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/ru.ts

@ -635,7 +635,7 @@ export default { @@ -635,7 +635,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -647,7 +647,7 @@ export default { @@ -647,7 +647,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/th.ts

@ -631,7 +631,7 @@ export default { @@ -631,7 +631,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -643,7 +643,7 @@ export default { @@ -643,7 +643,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

4
src/i18n/locales/zh.ts

@ -630,7 +630,7 @@ export default { @@ -630,7 +630,7 @@ export default {
'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.',
'eventArchive.sectionTitle': 'Notes & feed archive',
'eventArchive.sectionBlurb':
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events. Turn off to rely on relays only.',
'Keeps notes, reactions, and timeline order on disk so feeds can load offline or on slow links. Replaceable data (profiles, relay lists, publications) stays in its existing stores — this archive only fills gaps for “firehose” events.',
'eventArchive.defaultsMobile':
'This device profile uses small defaults: about {{lru}} events in memory, ~{{mb}} MB / {{ev}} archived events (reactions/zaps drop first).',
'eventArchive.defaultsElectron':
@ -642,7 +642,7 @@ export default { @@ -642,7 +642,7 @@ export default {
'eventArchive.maxEvents': 'Max archived events, blank = default',
'eventArchive.sessionLru': 'In-memory session cache (event count), blank = default',
'eventArchive.effectiveSummary':
'Currently: {{enabled}} — ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'Currently: ~{{mb}} MB budget, {{events}} events, {{lru}} session LRU.',
'eventArchive.on': 'on',
'eventArchive.off': 'off',
'eventArchive.apply': 'Apply cache settings',

26
src/lib/event-archive-config.ts

@ -1,6 +1,10 @@ @@ -1,6 +1,10 @@
import { StorageKey } from '@/constants'
import { isImwaldElectron, isMobileBrowserProfile } from '@/lib/client-platform'
/** Removed from settings; strip so manual `localStorage` edits cannot flip archive behavior. */
const LEGACY_EVENT_ARCHIVE_ENABLED_KEY = 'eventArchiveEnabled'
let legacyEventArchiveEnabledKeyRemoved = false
/** Platform defaults (overridable in Cache settings). */
export const EVENT_ARCHIVE_DEFAULTS = {
sessionLruMobile: 100,
@ -15,23 +19,12 @@ export const EVENT_ARCHIVE_DEFAULTS = { @@ -15,23 +19,12 @@ export const EVENT_ARCHIVE_DEFAULTS = {
} as const
export type TEventArchiveConfig = {
enabled: boolean
/** Soft byte budget (approximate, from JSON size). */
maxBytes: number
maxEvents: number
sessionLruMax: number
}
function readBool(key: string, defaultTrue: boolean): boolean {
try {
const v = window.localStorage.getItem(key)
if (v === null) return defaultTrue
return v !== 'false' && v !== '0'
} catch {
return defaultTrue
}
}
function readPositiveInt(key: string, fallback: number): number {
try {
const v = window.localStorage.getItem(key)
@ -63,14 +56,21 @@ function defaultMaxEvents(): number { @@ -63,14 +56,21 @@ function defaultMaxEvents(): number {
/**
* Effective archive + session LRU limits (reads Cache settings from localStorage).
* Disk archive is always on; only caps are configurable.
*/
export function getEventArchiveConfig(): TEventArchiveConfig {
const enabled = readBool(StorageKey.EVENT_ARCHIVE_ENABLED, true)
if (typeof window !== 'undefined' && !legacyEventArchiveEnabledKeyRemoved) {
legacyEventArchiveEnabledKeyRemoved = true
try {
window.localStorage.removeItem(LEGACY_EVENT_ARCHIVE_ENABLED_KEY)
} catch {
// ignore
}
}
const maxMb = readPositiveInt(StorageKey.EVENT_ARCHIVE_MAX_MB, defaultMaxMb())
const maxEvents = readPositiveInt(StorageKey.EVENT_ARCHIVE_MAX_EVENTS, defaultMaxEvents())
const sessionLruMax = readPositiveInt(StorageKey.SESSION_EVENT_LRU_MAX, defaultSessionLruMax())
return {
enabled,
maxBytes: Math.max(8, maxMb) * 1024 * 1024,
maxEvents: Math.max(50, maxEvents),
sessionLruMax: Math.max(32, Math.min(200_000, sessionLruMax))

11
src/services/event-archive.service.ts

@ -58,7 +58,6 @@ function approxEventBytes(ev: Event): number { @@ -58,7 +58,6 @@ function approxEventBytes(ev: Event): number {
async function trimArchiveIfNeeded(): Promise<void> {
const cfg = getEventArchiveConfig()
if (!cfg.enabled) return
await ensureFootprint()
let guard = 0
while (
@ -78,8 +77,7 @@ async function trimArchiveIfNeeded(): Promise<void> { @@ -78,8 +77,7 @@ async function trimArchiveIfNeeded(): Promise<void> {
}
async function flushArchiveQueue(): Promise<void> {
const cfg = getEventArchiveConfig()
if (!cfg.enabled || pending.size === 0) return
if (pending.size === 0) return
const batch = [...pending.values()]
pending.clear()
for (const ev of batch) {
@ -107,8 +105,6 @@ function scheduleFlush(): void { @@ -107,8 +105,6 @@ function scheduleFlush(): void {
/** Queue a non-replaceable event for IndexedDB archive (Electron + mobile + desktop web; caps differ). */
export function queuePersistSeenEvent(ev: Event): void {
const cfg = getEventArchiveConfig()
if (!cfg.enabled) return
if (shouldSkipArchiving(ev)) return
const id = /^[0-9a-f]{64}$/i.test(ev.id) ? ev.id.toLowerCase() : ev.id
if (!/^[0-9a-f]{64}$/.test(id)) return
@ -117,15 +113,12 @@ export function queuePersistSeenEvent(ev: Event): void { @@ -117,15 +113,12 @@ export function queuePersistSeenEvent(ev: Event): void {
}
export async function loadArchivedEventForFetch(hexId: string): Promise<Event | undefined> {
const cfg = getEventArchiveConfig()
if (!cfg.enabled) return undefined
const ev = await indexedDb.getArchivedEventById(hexId, true)
if (!ev || shouldDropEventOnIngest(ev)) return undefined
return ev
}
export async function prefetchArchivedEvents(hexIds: string[]): Promise<Event[]> {
const cfg = getEventArchiveConfig()
if (!cfg.enabled || hexIds.length === 0) return []
if (hexIds.length === 0) return []
return indexedDb.getArchivedEventsByIds(hexIds)
}

Loading…
Cancel
Save