Files
photon-tbw/src/lib/settings.ts
T
Peter Bui e028113ab0 feat: show compact posts (#22)
Add a new UI setting for showing compact posts:

- Show a small thumbnail to the right of the metadata and title if a
  thumbnail is available or if the post is an image
- Do not show normal thumbnail or text bodies.
2023-07-26 10:32:04 -07:00

45 lines
1003 B
TypeScript

import { writable } from 'svelte/store'
interface Settings {
newComments: boolean
expandableImages: boolean
markReadPosts: boolean
instance?: string
revertColors: boolean
showInstance: boolean
showCompactPosts: boolean
defaultSort: {
sort: 'Hot' | 'TopAll' | 'Active' | 'New'
feed: 'All' | 'Subscribed' | 'Local'
}
}
const defaultSettings: Settings = {
newComments: true,
expandableImages: true,
markReadPosts: true,
revertColors: false,
showInstance: false,
showCompactPosts: false,
defaultSort: {
sort: 'Active',
feed: 'Local',
},
}
export const userSettings = writable(defaultSettings)
if (typeof window != 'undefined') {
let oldUserSettings = JSON.parse(
localStorage.getItem('settings') ?? JSON.stringify(defaultSettings)
)
userSettings.set({...defaultSettings, ...oldUserSettings})
}
userSettings.subscribe((settings) => {
if (typeof window != 'undefined') {
localStorage.setItem('settings', JSON.stringify(settings))
}
})