From a3e48f8d5a373ad1475b82a0b30fcdc0197ccf13 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 10 Jun 2025 20:03:56 -0500 Subject: [PATCH] enhance --- src/state/unstable-post-source.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/state/unstable-post-source.tsx b/src/state/unstable-post-source.tsx index c24086f029..ac126d79c6 100644 --- a/src/state/unstable-post-source.tsx +++ b/src/state/unstable-post-source.tsx @@ -1,4 +1,4 @@ -import {useId, useState} from 'react' +import {useEffect, useId, useState} from 'react' import {type AppBskyFeedDefs, AtUri} from '@atproto/api' import {Logger} from '#/logger' @@ -57,12 +57,20 @@ export function useUnstablePostSource(key: string) { ) const source = consumedSources.get(id) || transientSources.get(key) if (source) { - logger.debug('consume', {key, source}) + logger.debug('consume', {id, key, source}) transientSources.delete(key) consumedSources.set(id, source) } return source }) + + useEffect(() => { + return () => { + consumedSources.delete(id) + logger.debug('cleanup', {id}) + } + }, [id]) + return source }