all-topics-cache-fix

This commit is contained in:
Untone 2024-08-05 14:03:30 +03:00
parent b53f83947c
commit e07ace8741
4 changed files with 13 additions and 7 deletions

View File

@ -1,3 +1,7 @@
{ {
"recommendations": ["biomejs.biome", "stylelint.vscode-stylelint", "wayou.vscode-todo-highlight"] "recommendations": [
"biomejs.biome",
"stylelint.vscode-stylelint",
"wayou.vscode-todo-highlight"
]
} }

View File

@ -68,7 +68,7 @@
"@tiptap/extension-youtube": "^2.5.8", "@tiptap/extension-youtube": "^2.5.8",
"@types/cookie": "^0.6.0", "@types/cookie": "^0.6.0",
"@types/cookie-signature": "^1.1.2", "@types/cookie-signature": "^1.1.2",
"@types/node": "^20.14.13", "@types/node": "^20.14.14",
"@types/throttle-debounce": "^5.0.2", "@types/throttle-debounce": "^5.0.2",
"@urql/core": "^5.0.5", "@urql/core": "^5.0.5",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
@ -98,8 +98,8 @@
"stylelint-config-recommended": "^14.0.1", "stylelint-config-recommended": "^14.0.1",
"stylelint-config-standard-scss": "^13.1.0", "stylelint-config-standard-scss": "^13.1.0",
"stylelint-order": "^6.0.4", "stylelint-order": "^6.0.4",
"stylelint-scss": "^6.4.1", "stylelint-scss": "^6.5.0",
"swiper": "^11.1.8", "swiper": "^11.1.9",
"throttle-debounce": "^5.0.2", "throttle-debounce": "^5.0.2",
"tslib": "^2.6.3", "tslib": "^2.6.3",
"typescript": "^5.5.4", "typescript": "^5.5.4",

View File

@ -157,10 +157,13 @@ export const TopicsProvider = (props: { children: JSX.Element }) => {
) )
setTopicEntities((prevTopicEntities) => { setTopicEntities((prevTopicEntities) => {
return { const ttt = {
...prevTopicEntities, ...prevTopicEntities,
...newTopicEntities ...newTopicEntities
} }
if (db()) saveTopicsToIndexedDB(db() as IDBDatabase, Object.values(ttt) as Topic[])
return ttt
}) })
} }
const [db, setDb] = createSignal() const [db, setDb] = createSignal()
@ -179,7 +182,6 @@ export const TopicsProvider = (props: { children: JSX.Element }) => {
const topicsLoader = loadTopics() const topicsLoader = loadTopics()
const ttt = await topicsLoader() const ttt = await topicsLoader()
ttt && addTopics(ttt) ttt && addTopics(ttt)
if (db()) await saveTopicsToIndexedDB(db() as IDBDatabase, ttt as Topic[])
return ttt || [] return ttt || []
} }

View File

@ -58,7 +58,7 @@ export default function TopicPage(props: RouteSectionProps<TopicPageProps>) {
async () => props.data.articles || (await fetchTopicShouts(props.params.slug)) || [] async () => props.data.articles || (await fetchTopicShouts(props.params.slug)) || []
) )
const title = createMemo(() => `${t('Discours')} :: ${topic()?.title || ''}`) const title = createMemo(() => `${t('Discours')}${ topic()?.title ? (` :: ${topic()?.title}`) : '' }`)
createEffect(() => { createEffect(() => {
if (topic() && window) { if (topic() && window) {