diff --git a/src/pages/contacts/contacts-view-state.test.ts b/src/pages/contacts/contacts-view-state.test.ts index d810cb0f..1540869a 100644 --- a/src/pages/contacts/contacts-view-state.test.ts +++ b/src/pages/contacts/contacts-view-state.test.ts @@ -12,6 +12,7 @@ import { shouldShowGroupmateSection, shouldShowContactsLoadingState, shouldHoldCompletedContactsTaskProgress, + shouldPreserveFriendActionRefreshRows, } from './contacts-view-state' function diagnostics(overrides: Partial = {}): ContactsDiagnostics { @@ -92,6 +93,14 @@ test('preserves scroll position for friend section friend actions', () => { ) }) +test('replaces friend rows after a groupmate is marked as friend', () => { + assert.equal(shouldPreserveFriendActionRefreshRows('friend'), false) +}) + +test('keeps preserving groupmate rows after local removal during friend actions', () => { + assert.equal(shouldPreserveFriendActionRefreshRows('non_friend'), true) +}) + test('shows groupmate section immediately when the groupmate tab is active', () => { assert.equal( shouldShowGroupmateSection({ diff --git a/src/pages/contacts/contacts-view-state.ts b/src/pages/contacts/contacts-view-state.ts index 005f39fe..b104ed93 100644 --- a/src/pages/contacts/contacts-view-state.ts +++ b/src/pages/contacts/contacts-view-state.ts @@ -50,6 +50,10 @@ export function resolveFriendActionScrollTop(state: FriendActionScrollState): nu return state.previousScrollTop } +export function shouldPreserveFriendActionRefreshRows(pool: ContactPoolTab): boolean { + return pool !== 'friend' +} + export function shouldShowGroupmateSection(state: GroupmateSectionVisibilityState): boolean { return state.activeSection === 'non_friend' || state.friendSectionReady } diff --git a/src/pages/contacts/index.vue b/src/pages/contacts/index.vue index f67317db..e5c359d2 100644 --- a/src/pages/contacts/index.vue +++ b/src/pages/contacts/index.vue @@ -22,6 +22,7 @@ import { resolveFriendActionScrollTop, resolveContactsPollingPools, shouldHoldCompletedContactsTaskProgress, + shouldPreserveFriendActionRefreshRows, shouldShowContactsDisabledNotice, shouldShowContactsLoadingState, shouldShowGroupmateSection, @@ -649,13 +650,13 @@ async function refreshContactsPageMetadata() { loadContactsPage('friend', 1, { acceptStale: true, replace: true, - preserveExisting: true, + preserveExisting: shouldPreserveFriendActionRefreshRows('friend'), silent: true, }), loadContactsPage('non_friend', 1, { acceptStale: true, replace: true, - preserveExisting: true, + preserveExisting: shouldPreserveFriendActionRefreshRows('non_friend'), silent: true, }), ])