mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Dont revalidate shortcuts on focus to reduce flicker
This commit is contained in:
parent
613dd39aba
commit
c3ae9e7ac6
4 changed files with 6 additions and 5 deletions
|
|
@ -75,7 +75,6 @@ export function HomeContainer(): JSX.Element {
|
|||
>
|
||||
{homeData.sections?.map((homeSection, idx) => {
|
||||
if (homeSection.items.length < 1) {
|
||||
console.log('empty home section: ', homeSection)
|
||||
return <SpanBox key={`section-${idx}`}></SpanBox>
|
||||
}
|
||||
switch (homeSection.layout) {
|
||||
|
|
@ -224,7 +223,6 @@ const TopPicksHomeSection = (props: HomeSectionProps): JSX.Element => {
|
|||
items?: HomeItem[]
|
||||
}
|
||||
) => {
|
||||
console.log('handling action: ', action)
|
||||
switch (action.type) {
|
||||
case 'RESET':
|
||||
return action.items ?? []
|
||||
|
|
|
|||
|
|
@ -185,6 +185,8 @@ const Shortcuts = (props: LibraryFilterMenuProps): JSX.Element => {
|
|||
initialValue: [],
|
||||
})
|
||||
|
||||
console.log('got shortcuts: ', shortcuts)
|
||||
|
||||
// const shortcuts: Shortcut[] = [
|
||||
// {
|
||||
// id: '12asdfasdf',
|
||||
|
|
|
|||
|
|
@ -375,6 +375,7 @@ async function setShortcuts(
|
|||
|
||||
async function resetShortcuts(path: string): Promise<Shortcut[]> {
|
||||
const url = new URL(path, fetchEndpoint)
|
||||
console.log('resetting shortcuts')
|
||||
try {
|
||||
const response = await fetch(url.toString(), {
|
||||
method: 'DELETE',
|
||||
|
|
@ -399,10 +400,12 @@ async function resetShortcuts(path: string): Promise<Shortcut[]> {
|
|||
const cachedShortcutsData = (): Shortcut[] | undefined => {
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
const str = localStorage.getItem('/api/shortcuts')
|
||||
console.log('cached shortcuts: ', str)
|
||||
if (str) {
|
||||
return JSON.parse(str) as Shortcut[]
|
||||
}
|
||||
}
|
||||
console.log('undefined shortcuts')
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
|
@ -411,6 +414,7 @@ const ShortcutsTree = (props: ShortcutsTreeProps): JSX.Element => {
|
|||
const { ref, width, height } = useResizeObserver()
|
||||
|
||||
const { isValidating, data } = useSWR('/api/shortcuts', getShortcuts, {
|
||||
revalidateOnFocus: false,
|
||||
fallbackData: cachedShortcutsData(),
|
||||
onSuccess(data) {
|
||||
localStorage.setItem('/api/shortcuts', JSON.stringify(data))
|
||||
|
|
|
|||
|
|
@ -147,8 +147,6 @@ export function useGetHomeItems(): HomeItemResponse {
|
|||
}
|
||||
|
||||
const result = data as HomeResult
|
||||
console.log('result: ', result)
|
||||
|
||||
if (result && result.home.errorCodes) {
|
||||
const errorCodes = result.home.errorCodes
|
||||
return {
|
||||
|
|
@ -159,7 +157,6 @@ export function useGetHomeItems(): HomeItemResponse {
|
|||
}
|
||||
|
||||
if (result && result.home && result.home.edges) {
|
||||
console.log('data', result.home)
|
||||
return {
|
||||
mutate,
|
||||
error: false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue