@@ -891,6 +891,7 @@ export type attachmentListOptions = {
891891export function attachmentList ( dom : HTMLDocument , subject : NamedNode , div : HTMLElement , options : attachmentListOptions = { } ) {
892892 // options = options || {}
893893 const docsWaitingForRowRefresh = new Set < string > ( )
894+ const hasAsyncEnrichedRowOptions = ! ! ( options . renderSupportingInfo || options . renderNameSuffix )
894895
895896 const deleteAttachment = function ( target ) {
896897 if ( ! kb . updater ) {
@@ -917,9 +918,11 @@ export function attachmentList (dom: HTMLDocument, subject: NamedNode, div: HTML
917918 opt . renderSupportingInfo = options . renderSupportingInfo
918919 opt . renderNameSuffix = options . renderNameSuffix
919920
920- if ( ( options . renderSupportingInfo || options . renderNameSuffix ) && target ?. uri && kb . fetcher ) {
921+ if ( hasAsyncEnrichedRowOptions && target ?. uri && kb . fetcher ) {
921922 const targetDoc = target . doc ( )
922- if ( targetDoc ?. uri && ! docsWaitingForRowRefresh . has ( targetDoc . uri ) ) {
923+ const requestState = targetDoc ?. uri ? kb . fetcher . requested ?. [ targetDoc . uri ] : undefined
924+ const shouldWaitForFetch = requestState !== 'done' && requestState !== 'failed'
925+ if ( targetDoc ?. uri && shouldWaitForFetch && ! docsWaitingForRowRefresh . has ( targetDoc . uri ) ) {
923926 docsWaitingForRowRefresh . add ( targetDoc . uri )
924927 // Root fix: these row options can depend on async profile data, so rerender once fetch completes.
925928 kb . fetcher . nowOrWhenFetched ( targetDoc , undefined , ( ) => {
@@ -940,7 +943,18 @@ export function attachmentList (dom: HTMLDocument, subject: NamedNode, div: HTML
940943 const refresh = function ( ) {
941944 const things = kb . each ( subject , predicate )
942945 things . sort ( )
943- utils . syncTableToArray ( attachmentTable , things , createNewRow )
946+ utils . syncTableToArray (
947+ attachmentTable ,
948+ things ,
949+ createNewRow ,
950+ hasAsyncEnrichedRowOptions
951+ ? function ( row , thing ) {
952+ // When row content depends on async profile data, recreate matched rows on refresh.
953+ const replacement = createNewRow ( thing )
954+ return replacement
955+ }
956+ : undefined
957+ )
944958 }
945959
946960 function droppedURIHandler ( uris ) {
0 commit comments