Do less work (#1953)
This commit is contained in:
parent
9c8a1b8a31
commit
c858b58307
6 changed files with 24 additions and 29 deletions
10
src/state/cache/post-shadow.ts
vendored
10
src/state/cache/post-shadow.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
import {useEffect, useState, useCallback, useRef} from 'react'
|
||||
import {useEffect, useState, useMemo, useCallback, useRef} from 'react'
|
||||
import EventEmitter from 'eventemitter3'
|
||||
import {AppBskyFeedDefs} from '@atproto/api'
|
||||
import {Shadow} from './types'
|
||||
|
@ -55,9 +55,11 @@ export function usePostShadow(
|
|||
firstRun.current = false
|
||||
}, [post])
|
||||
|
||||
return state.ts > ifAfterTS
|
||||
? mergeShadow(post, state.value)
|
||||
: {...post, isShadowed: true}
|
||||
return useMemo(() => {
|
||||
return state.ts > ifAfterTS
|
||||
? mergeShadow(post, state.value)
|
||||
: {...post, isShadowed: true}
|
||||
}, [post, state, ifAfterTS])
|
||||
}
|
||||
|
||||
export function updatePostShadow(uri: string, value: Partial<PostShadow>) {
|
||||
|
|
10
src/state/cache/profile-shadow.ts
vendored
10
src/state/cache/profile-shadow.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
import {useEffect, useState, useCallback, useRef} from 'react'
|
||||
import {useEffect, useState, useMemo, useCallback, useRef} from 'react'
|
||||
import EventEmitter from 'eventemitter3'
|
||||
import {AppBskyActorDefs} from '@atproto/api'
|
||||
import {Shadow} from './types'
|
||||
|
@ -56,9 +56,11 @@ export function useProfileShadow(
|
|||
firstRun.current = false
|
||||
}, [profile])
|
||||
|
||||
return state.ts > ifAfterTS
|
||||
? mergeShadow(profile, state.value)
|
||||
: {...profile, isShadowed: true}
|
||||
return useMemo(() => {
|
||||
return state.ts > ifAfterTS
|
||||
? mergeShadow(profile, state.value)
|
||||
: {...profile, isShadowed: true}
|
||||
}, [profile, state, ifAfterTS])
|
||||
}
|
||||
|
||||
export function updateProfileShadow(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue