Skip to content

Commit

Permalink
Update local story distribution list in more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed May 19, 2023
1 parent b173283 commit 579329b
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions ts/services/storageRecordOps.ts
Expand Up @@ -1583,36 +1583,20 @@ export async function mergeStoryDistributionListRecord(
uuid => !remoteMemberListSet.has(uuid)
);

const needsUpdate = Boolean(
needsToClearUnknownFields || hasConflict || toAdd.length || toRemove.length
);

if (!needsUpdate) {
details.push('not updated');
return {
details: [...details, ...conflictDetails],
hasConflict,
oldStorageID,
oldStorageVersion,
};
}

if (needsUpdate) {
details.push('updated');
await dataInterface.modifyStoryDistributionWithMembers(storyDistribution, {
toAdd,
toRemove,
});
window.reduxActions.storyDistributionLists.modifyDistributionList({
allowsReplies: Boolean(storyDistribution.allowsReplies),
deletedAtTimestamp: storyDistribution.deletedAtTimestamp,
id: storyDistribution.id,
isBlockList: Boolean(storyDistribution.isBlockList),
membersToAdd: toAdd,
membersToRemove: toRemove,
name: storyDistribution.name,
});
}
details.push('updated');
await dataInterface.modifyStoryDistributionWithMembers(storyDistribution, {
toAdd,
toRemove,
});
window.reduxActions.storyDistributionLists.modifyDistributionList({
allowsReplies: Boolean(storyDistribution.allowsReplies),
deletedAtTimestamp: storyDistribution.deletedAtTimestamp,
id: storyDistribution.id,
isBlockList: Boolean(storyDistribution.isBlockList),
membersToAdd: toAdd,
membersToRemove: toRemove,
name: storyDistribution.name,
});

return {
details: [...details, ...conflictDetails],
Expand Down

0 comments on commit 579329b

Please sign in to comment.