fix: entry content processing, if local db data broken
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
c969627c68
commit
483d87e38c
|
|
@ -37,23 +37,24 @@ export const EntryContent = ({ entryId }: { entryId: ActiveEntryId }) => {
|
|||
}
|
||||
|
||||
function EntryContentRender({ entryId }: { entryId: string }) {
|
||||
const { error } = useBizQuery(Queries.entries.byId(entryId), {
|
||||
const { error, data } = useBizQuery(Queries.entries.byId(entryId), {
|
||||
staleTime: 300_000,
|
||||
})
|
||||
|
||||
const entry = useEntry(entryId)
|
||||
|
||||
const [content, setContent] = useState<JSX.Element>()
|
||||
|
||||
useEffect(() => {
|
||||
if (entry?.entries.content) {
|
||||
parseHtml(entry?.entries.content).then((parsed) => {
|
||||
// Fallback data, if local data is broken should fallback to cached query data.
|
||||
const processContent = entry?.entries.content ?? data?.entries.content
|
||||
if (processContent) {
|
||||
parseHtml(processContent).then((parsed) => {
|
||||
setContent(parsed.content)
|
||||
})
|
||||
} else {
|
||||
setContent(undefined)
|
||||
}
|
||||
}, [entry?.entries.content])
|
||||
}, [data?.entries.content, entry?.entries.content])
|
||||
|
||||
const translation = useBizQuery(
|
||||
Queries.ai.translation({
|
||||
|
|
|
|||
Loading…
Reference in New Issue