fix: pr review fixes

pull/2454/head
William Grant 3 years ago
parent b33ea096b4
commit bbfb55f211

@ -216,15 +216,17 @@ const handleSenders = (senders: Array<string>, me: string) => {
export const ReactListModal = (props: Props): ReactElement => { export const ReactListModal = (props: Props): ReactElement => {
const { reaction, messageId } = props; const { reaction, messageId } = props;
const dispatch = useDispatch();
const [reactions, setReactions] = useState<SortedReactionList>([]); const [reactions, setReactions] = useState<SortedReactionList>([]);
const reactionsMap = (reactions && Object.fromEntries(reactions)) || {}; const reactionsMap = (reactions && Object.fromEntries(reactions)) || {};
const [currentReact, setCurrentReact] = useState(''); const [currentReact, setCurrentReact] = useState('');
const [reactAriaLabel, setReactAriaLabel] = useState<string | undefined>(); const [reactAriaLabel, setReactAriaLabel] = useState<string | undefined>();
const [count, setCount] = useState<number | null>(null); const [count, setCount] = useState<number | null>(null);
const [senders, setSenders] = useState<Array<string>>([]); const [senders, setSenders] = useState<Array<string>>([]);
const me = UserUtils.getOurPubKeyStrFromCache();
const msgProps = useMessageReactsPropsById(messageId); const msgProps = useMessageReactsPropsById(messageId);
const weAreModerator = useWeAreModerator(msgProps?.convoId);
const me = UserUtils.getOurPubKeyStrFromCache();
// tslint:disable: cyclomatic-complexity // tslint:disable: cyclomatic-complexity
useEffect(() => { useEffect(() => {
@ -281,10 +283,7 @@ export const ReactListModal = (props: Props): ReactElement => {
return <></>; return <></>;
} }
const dispatch = useDispatch(); const { isPublic } = msgProps;
const { convoId, isPublic } = msgProps;
const weAreModerator = useWeAreModerator(convoId);
const handleSelectedReaction = (emoji: string): boolean => { const handleSelectedReaction = (emoji: string): boolean => {
return currentReact === emoji; return currentReact === emoji;

@ -57,10 +57,8 @@ export function updateMutationCache(entry: SogsV3Mutation, seqno: number) {
} else { } else {
const entryIndex = findIndex(sogsMutationCache, entry); const entryIndex = findIndex(sogsMutationCache, entry);
if (entryIndex >= 0) { if (entryIndex >= 0) {
const updatedEntry = entry; sogsMutationCache[entryIndex].seqno = seqno;
updatedEntry.seqno = seqno; window.log.info('SOGS Mutation Cache: Entry updated!', sogsMutationCache[entryIndex]);
sogsMutationCache[entryIndex] = updatedEntry;
window.log.info('SOGS Mutation Cache: Entry updated!', updatedEntry);
} else { } else {
window.log.error('SOGS Mutation Cache: Updated failed! Cannot find entry', entry); window.log.error('SOGS Mutation Cache: Updated failed! Cannot find entry', entry);
} }
@ -75,7 +73,6 @@ export async function processMessagesUsingCache(
const updatedReactions = message.reactions; const updatedReactions = message.reactions;
const roomMatches: Array<SogsV3Mutation> = filter(sogsMutationCache, { server, room }); const roomMatches: Array<SogsV3Mutation> = filter(sogsMutationCache, { server, room });
if (roomMatches?.length) {
for (const roomMatch of roomMatches) { for (const roomMatch of roomMatches) {
if (message.seqno && roomMatch.seqno && roomMatch.seqno <= message.seqno) { if (message.seqno && roomMatch.seqno && roomMatch.seqno <= message.seqno) {
const removedEntry = remove(sogsMutationCache, roomMatch); const removedEntry = remove(sogsMutationCache, roomMatch);
@ -94,7 +91,7 @@ export async function processMessagesUsingCache(
emoji: reaction, emoji: reaction,
}, },
}); });
if (reactionMatches?.length) {
for (const reactionMatch of reactionMatches) { for (const reactionMatch of reactionMatches) {
switch (reactionMatch.metadata.action) { switch (reactionMatch.metadata.action) {
case 'ADD': case 'ADD':
@ -120,18 +117,13 @@ export async function processMessagesUsingCache(
); );
} }
} }
const removedMatches = remove(sogsMutationCache, ...roomMatches);
window.log.info(
'SOGS Mutation Cache: Removed processed entries from cache!',
removedMatches
);
}
}
} }
} }
} }
const removedMatches = remove(sogsMutationCache, ...roomMatches);
window.log.info('SOGS Mutation Cache: Removed processed entries from cache!', removedMatches);
message.reactions = updatedReactions; message.reactions = updatedReactions;
await handleOpenGroupMessageReactions(message.reactions, message.id); await handleOpenGroupMessageReactions(message.reactions, message.id);
} }

Loading…
Cancel
Save