diff --git a/package/src/components/Chat/hooks/handleEventToSyncDB.ts b/package/src/components/Chat/hooks/handleEventToSyncDB.ts index f53357c422..d93bf5715f 100644 --- a/package/src/components/Chat/hooks/handleEventToSyncDB.ts +++ b/package/src/components/Chat/hooks/handleEventToSyncDB.ts @@ -124,8 +124,7 @@ export const handleEventToSyncDB = < if (type === 'reaction.updated') { const message = event.message; if (message && event.reaction) { - // We update the entire message to make sure we also update - // reaction_counts. + // We update the entire message to make sure we also update reaction_groups return queriesWithChannelGuard((flushOverride) => updateMessage({ flush: flushOverride, diff --git a/package/src/store/QuickSqliteClient.ts b/package/src/store/QuickSqliteClient.ts index 7eae812dc3..440c96d647 100644 --- a/package/src/store/QuickSqliteClient.ts +++ b/package/src/store/QuickSqliteClient.ts @@ -30,7 +30,7 @@ import type { PreparedQueries, Table } from './types'; * */ export class QuickSqliteClient { - static dbVersion = 3; + static dbVersion = 4; static dbName = DB_NAME; static dbLocation = DB_LOCATION; diff --git a/package/src/store/apis/insertReaction.ts b/package/src/store/apis/insertReaction.ts index 3bf099ada8..f9bee7778f 100644 --- a/package/src/store/apis/insertReaction.ts +++ b/package/src/store/apis/insertReaction.ts @@ -21,14 +21,12 @@ export const insertReaction = ({ queries.push(createUpsertQuery('reactions', storableReaction)); - const stringifiedNewReactionCounts = JSON.stringify(message.reaction_counts); const stringifiedNewReactionGroups = JSON.stringify(message.reaction_groups); queries.push( createUpdateQuery( 'messages', { - reactionCounts: stringifiedNewReactionCounts, reactionGroups: stringifiedNewReactionGroups, }, { id: reaction.message_id }, diff --git a/package/src/store/apis/updateReaction.ts b/package/src/store/apis/updateReaction.ts index e374a0488f..d7a797cce7 100644 --- a/package/src/store/apis/updateReaction.ts +++ b/package/src/store/apis/updateReaction.ts @@ -36,23 +36,6 @@ export const updateReaction = ({ let updatedReactionCounts: string | undefined; - if (message.reaction_counts) { - const { reactionCounts } = mapMessageToStorable(message); - updatedReactionCounts = reactionCounts; - - queries.push( - createUpdateQuery( - 'messages', - { - reactionCounts, - }, - { - id: message.id, - }, - ), - ); - } - let updatedReactionGroups: string | undefined; if (message.reaction_groups) { const { reactionGroups } = mapMessageToStorable(message); diff --git a/package/src/store/mappers/mapMessageToStorable.ts b/package/src/store/mappers/mapMessageToStorable.ts index 6ee96f3aa3..b38edf0b97 100644 --- a/package/src/store/mappers/mapMessageToStorable.ts +++ b/package/src/store/mappers/mapMessageToStorable.ts @@ -17,7 +17,6 @@ export const mapMessageToStorable = ( latest_reactions, // eslint-disable-next-line @typescript-eslint/no-unused-vars own_reactions, - reaction_counts, reaction_groups, text, type, @@ -33,7 +32,6 @@ export const mapMessageToStorable = ( deletedAt: mapDateTimeToStorable(deleted_at), extraData: JSON.stringify(extraData), id, - reactionCounts: JSON.stringify(reaction_counts), reactionGroups: JSON.stringify(reaction_groups), text, type, diff --git a/package/src/store/mappers/mapStorableToMessage.ts b/package/src/store/mappers/mapStorableToMessage.ts index 846483d7ff..a051cab001 100644 --- a/package/src/store/mappers/mapStorableToMessage.ts +++ b/package/src/store/mappers/mapStorableToMessage.ts @@ -19,16 +19,7 @@ export const mapStorableToMessage = < messageRow: TableRowJoinedUser<'messages'>; reactionRows: TableRowJoinedUser<'reactions'>[]; }): MessageResponse => { - const { - createdAt, - deletedAt, - extraData, - reactionCounts, - reactionGroups, - updatedAt, - user, - ...rest - } = messageRow; + const { createdAt, deletedAt, extraData, reactionGroups, updatedAt, user, ...rest } = messageRow; const latestReactions = reactionRows?.map((reaction) => mapStorableToReaction(reaction)) || []; @@ -41,7 +32,6 @@ export const mapStorableToMessage = < deleted_at: deletedAt, latest_reactions: latestReactions, own_reactions: ownReactions, - reaction_counts: reactionCounts ? JSON.parse(reactionCounts) : {}, reaction_groups: reactionGroups ? JSON.parse(reactionGroups) : {}, updated_at: updatedAt, user: mapStorableToUser(user), diff --git a/package/src/store/schema.ts b/package/src/store/schema.ts index d71e548a38..4b3834d34e 100644 --- a/package/src/store/schema.ts +++ b/package/src/store/schema.ts @@ -102,7 +102,6 @@ export const tables: Tables = { deletedAt: 'TEXT', extraData: 'TEXT', id: 'TEXT', - reactionCounts: 'TEXT', reactionGroups: 'TEXT', text: "TEXT DEFAULT ''", type: 'TEXT', @@ -263,7 +262,6 @@ export type Schema = { deletedAt: string; extraData: string; id: string; - reactionCounts: string; reactionGroups: string; type: MessageLabel; updatedAt: string; diff --git a/package/src/utils/addReactionToLocalState.ts b/package/src/utils/addReactionToLocalState.ts index ead1a620bd..b3a81dd613 100644 --- a/package/src/utils/addReactionToLocalState.ts +++ b/package/src/utils/addReactionToLocalState.ts @@ -49,15 +49,6 @@ export const addReactionToLocalState = < message.latest_reactions = []; } message.latest_reactions = message.latest_reactions.filter((r) => r.user_id !== user.id); - if ( - currentReaction && - message.reaction_counts && - message.reaction_counts[currentReaction.type] && - message.reaction_counts[currentReaction.type] > 0 - ) { - message.reaction_counts[currentReaction.type] = - message.reaction_counts[currentReaction.type] - 1; - } if ( currentReaction && @@ -72,14 +63,6 @@ export const addReactionToLocalState = < message.reaction_groups[currentReaction.type].sum_scores - 1; } - if (!message.reaction_counts) { - message.reaction_counts = { - [reactionType]: 1, - }; - } else { - message.reaction_counts[reactionType] = (message.reaction_counts?.[reactionType] || 0) + 1; - } - if (!message.reaction_groups) { message.reaction_groups = { [reactionType]: { @@ -107,14 +90,6 @@ export const addReactionToLocalState = < } } } else { - if (!message.reaction_counts) { - message.reaction_counts = { - [reactionType]: 1, - }; - } else { - message.reaction_counts[reactionType] = (message.reaction_counts?.[reactionType] || 0) + 1; - } - if (!message.reaction_groups) { message.reaction_groups = { [reactionType]: { diff --git a/package/src/utils/removeReactionFromLocalState.ts b/package/src/utils/removeReactionFromLocalState.ts index cf8ecd6289..12f7f96a99 100644 --- a/package/src/utils/removeReactionFromLocalState.ts +++ b/package/src/utils/removeReactionFromLocalState.ts @@ -46,17 +46,6 @@ export const removeReactionFromLocalState = < } } - if (message.reaction_counts?.[reactionType]) { - if (message.reaction_counts[reactionType] > 0) { - message.reaction_counts[reactionType] = message.reaction_counts[reactionType] - 1; - if (message.reaction_counts[reactionType] === 0) { - delete message.reaction_counts[reactionType]; - } - } else { - delete message.reaction_counts[reactionType]; - } - } - deleteReaction({ messageId, reactionType,