@@ -22,6 +22,7 @@ import { createIncomingSharePayloadReader } from "./incoming-share-native";
2222import { IncomingShareInbox } from "./incoming-share-inbox" ;
2323import { persistComposerAttachmentFile } from "../../lib/composerImages" ;
2424import { subscribeAppActive } from "../../lib/appState" ;
25+ import { coalescedRun } from "../../lib/coalescedRun" ;
2526import { rootNavigationRef } from "../../lib/rootNavigation" ;
2627import { selectWorkspaceDetail } from "../workspace/workspace-detail-selection" ;
2728import { isDraftThreadRoute } from "../threads/thread-route-state" ;
@@ -196,7 +197,6 @@ interface IncomingShareSnapshot {
196197
197198let snapshot : IncomingShareSnapshot = { drafts : [ ] , isLoading : true } ;
198199const snapshotListeners = new Set < ( ) => void > ( ) ;
199- let refreshInFlight : Promise < void > | null = null ;
200200let presentation = EMPTY_INCOMING_SHARE_PRESENTATION_STATE ;
201201
202202function publish ( drafts : ReadonlyArray < IncomingShareDraft > ) {
@@ -224,22 +224,18 @@ function reportRefreshFailure(cause: unknown) {
224224 ] ) ;
225225}
226226
227- function refreshIncomingShares ( ) : Promise < void > {
228- if ( refreshInFlight ) return refreshInFlight ;
227+ // A resume while a refresh runs may carry a native handoff that refresh already
228+ // passed, so it queues one more refresh instead of joining the running one.
229+ const refreshIncomingShares = coalescedRun ( async ( ) => {
229230 const enabled = receiveSharingEnabled ( ) ;
230- refreshInFlight = ( async ( ) => {
231- try {
232- publish ( await incomingShareInbox . refresh ( { ingestNative : enabled } ) ) ;
233- } catch ( cause ) {
234- const persisted = await incomingShareInbox . refresh ( { ingestNative : false } ) . catch ( ( ) => null ) ;
235- publish ( persisted ?? snapshot . drafts ) ;
236- reportRefreshFailure ( cause ) ;
237- }
238- } ) ( ) . finally ( ( ) => {
239- refreshInFlight = null ;
240- } ) ;
241- return refreshInFlight ;
242- }
231+ try {
232+ publish ( await incomingShareInbox . refresh ( { ingestNative : enabled } ) ) ;
233+ } catch ( cause ) {
234+ const persisted = await incomingShareInbox . refresh ( { ingestNative : false } ) . catch ( ( ) => null ) ;
235+ publish ( persisted ?? snapshot . drafts ) ;
236+ reportRefreshFailure ( cause ) ;
237+ }
238+ } ) ;
243239
244240/**
245241 * Opens the oldest pending share as a new-task draft unless the user already
0 commit comments