Skip to content

Commit

Permalink
[lib] reduce thread updates from createOrUpdateFarcasterChannelTag an…
Browse files Browse the repository at this point in the history
…d deleteFarcasterChannelTag

Summary: Depends on D13779

Test Plan:
tested setting and unsetting community tags from a client running an older code version and it worked as expected -- no crashes, communities and threads tables updated on keyserver. eventually the state check mechanism synced the client threads with the keyserver

tested the same thing on a new client that can receive the thread changes directly and confirmed that the actions were reduced correctly and the redux state thread info looked right

Reviewers: ashoat

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D13788
  • Loading branch information
vdhanan committed Oct 25, 2024
1 parent 5ca379f commit 7fa2310
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/reducers/message-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import _pickBy from 'lodash/fp/pickBy.js';
import _uniq from 'lodash/fp/uniq.js';

import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import {
createOrUpdateFarcasterChannelTagActionTypes,
deleteFarcasterChannelTagActionTypes,
} from '../actions/community-actions.js';
import {
createEntryActionTypes,
saveEntryActionTypes,
Expand Down Expand Up @@ -1046,6 +1050,21 @@ function reduceMessageStore(
},
newThreadInfos,
);
} else if (
(action.type === createOrUpdateFarcasterChannelTagActionTypes.success &&
action.payload.newMessageInfos) ||
(action.type === deleteFarcasterChannelTagActionTypes.success &&
action.payload.newMessageInfos)
) {
return mergeNewMessages(
messageStore,
action.payload.newMessageInfos,
{
[(action.payload.commCommunityID: string)]:
messageTruncationStatus.UNCHANGED,
},
newThreadInfos,
);
} else if (action.type === deleteEntryActionTypes.success) {
const payload = action.payload;
if (payload) {
Expand Down
15 changes: 14 additions & 1 deletion lib/reducers/thread-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
} from '../actions/activity-actions.js';
import { removePeerUsersActionType } from '../actions/aux-user-actions.js';
import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import {
createOrUpdateFarcasterChannelTagActionTypes,
deleteFarcasterChannelTagActionTypes,
} from '../actions/community-actions.js';
import { saveMessagesActionType } from '../actions/message-actions.js';
import { legacySiweAuthActionTypes } from '../actions/siwe-actions.js';
import {
Expand Down Expand Up @@ -264,8 +268,17 @@ function reduceThreadInfos(
action.type === newThreadActionTypes.success ||
action.type === modifyCommunityRoleActionTypes.success ||
action.type === deleteCommunityRoleActionTypes.success ||
action.type === removePeerUsersActionType
action.type === removePeerUsersActionType ||
action.type === createOrUpdateFarcasterChannelTagActionTypes.success ||
action.type === deleteFarcasterChannelTagActionTypes.success
) {
if (!action.payload.updatesResult) {
return {
threadStore: state,
newThreadInconsistencies: [],
threadStoreOperations: [],
};
}
const { newUpdates } = action.payload.updatesResult;
if (newUpdates.length === 0) {
return {
Expand Down

0 comments on commit 7fa2310

Please sign in to comment.