Handle post deletions by removing from active views (close #37)

This commit is contained in:
Paul Frazee 2023-01-18 16:45:48 -06:00
parent ace0e6bfd9
commit ebc2033d18
7 changed files with 59 additions and 4 deletions

View file

@ -102,7 +102,7 @@ export const PostThreadItem = observer(function PostThreadItem({
if (deleted) {
return (
<View style={[styles.outer, pal.view, s.p20, s.flexRow]}>
<View style={[styles.outer, pal.border, pal.view, s.p20, s.flexRow]}>
<FontAwesomeIcon
icon={['far', 'trash-can']}
style={{color: pal.colors.icon}}

View file

@ -46,9 +46,11 @@ export const Home = observer(function Home({
)
useEffect(() => {
const feedCleanup = store.me.mainFeed.registerListeners()
const pollInterval = setInterval(() => doPoll(), 15e3)
const cleanup = () => {
clearInterval(pollInterval)
feedCleanup()
}
if (!visible) {

View file

@ -25,8 +25,9 @@ export const PostThread = ({navIdx, visible, params}: ScreenParams) => {
}
useEffect(() => {
let aborted = false
const threadCleanup = view.registerListeners()
if (!visible) {
return
return threadCleanup
}
setTitle()
store.shell.setMinimalShellMode(false)
@ -44,6 +45,7 @@ export const PostThread = ({navIdx, visible, params}: ScreenParams) => {
}
return () => {
aborted = true
threadCleanup()
}
}, [visible, store.nav, store.log, name])

View file

@ -31,8 +31,9 @@ export const Profile = observer(({navIdx, visible, params}: ScreenParams) => {
useEffect(() => {
let aborted = false
const feedCleanup = uiState.feed.registerListeners()
if (!visible) {
return
return feedCleanup
}
if (hasSetup) {
uiState.update()
@ -45,6 +46,7 @@ export const Profile = observer(({navIdx, visible, params}: ScreenParams) => {
}
return () => {
aborted = true
feedCleanup()
}
}, [visible, params.name, store])