Skip to content

Commit 7ae67df

Browse files
authored
emoji shortnames can conflict which causes a key clash (keybase#25559)
* emoji shortnames can conflict which causes a key clash * lint
1 parent 15bb310 commit 7ae67df

9 files changed

Lines changed: 29 additions & 29 deletions

File tree

‎shared/actions/chat2/index.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,12 +2371,12 @@ const markThreadAsRead = async (
23712371
logger.info(`marking read messages ${conversationIDKey} ${readMsgID} for ${action.type}`)
23722372
await RPCChatTypes.localMarkAsReadLocalRpcPromise({
23732373
conversationID: Types.keyToConversationID(conversationIDKey),
2374-
msgID: readMsgID,
23752374
forceUnread: false,
2375+
msgID: readMsgID,
23762376
})
23772377
}
23782378

2379-
const markAsUnread = async (state: Container.TypedState, action: Chat2Gen.MarkAsUnreadPayload) => {
2379+
const markAsUnread = (state: Container.TypedState, action: Chat2Gen.MarkAsUnreadPayload) => {
23802380
if (!state.config.loggedIn) {
23812381
logger.info('bail on not logged in')
23822382
return
@@ -2401,8 +2401,8 @@ const markAsUnread = async (state: Container.TypedState, action: Chat2Gen.MarkAs
24012401
logger.info(`marking unread messages ${conversationIDKey} ${readMsgID}`)
24022402
RPCChatTypes.localMarkAsReadLocalRpcPromise({
24032403
conversationID: Types.keyToConversationID(conversationIDKey),
2404-
msgID: message ? message.id : unreadLineID,
24052404
forceUnread: true,
2405+
msgID: message ? message.id : unreadLineID,
24062406
})
24072407
.then(() => {})
24082408
.catch(() => {})

‎shared/chat/conversation/input-area/suggestors/common.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export type ItemRendererProps<T> = {selected: boolean; item: T; conversationIDKe
4848
export type ListProps<T> = {
4949
expanded: boolean
5050
items: Array<T>
51-
keyExtractor: (item: T) => string
51+
keyExtractor: (item: T, idx: number) => string
5252
suggestBotCommandsUpdateStatus?: RPCChatTypes.UIBotCommandsUpdateStatusTyp
5353
listStyle: Styles.StylesCrossPlatform
5454
spinnerStyle: Styles.StylesCrossPlatform
@@ -67,7 +67,7 @@ export function List<T>(p: ListProps<T>) {
6767

6868
const renderItem = React.useCallback(
6969
(idx, item: T) => (
70-
<Kb.ClickableBox key={keyExtractor(item)} onClick={() => onSelected(item, true)}>
70+
<Kb.ClickableBox key={keyExtractor(item, idx)} onClick={() => onSelected(item, true)}>
7171
<ItemRenderer selected={idx === selectedIndex} item={item} conversationIDKey={conversationIDKey} />
7272
</Kb.ClickableBox>
7373
),

‎shared/chat/conversation/input-area/suggestors/emoji.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const transformer = (
2525
return Common.standardTransformer(`${marker}${emoji.short_name}:`, tData, preview)
2626
}
2727

28-
const keyExtractor = (item: EmojiData) => item.short_name
28+
const keyExtractor = (_item: EmojiData, idx: number) => String(idx) // emojis can have conflicts on the names
2929

3030
const ItemRenderer = (p: Common.ItemRendererProps<EmojiData>) => {
3131
const {item, selected} = p

‎shared/chat/conversation/input-area/suggestors/suggestion-list.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as RPCChatTypes from '../../../../constants/types/rpc-chat-gen'
44

55
export type Props = {
66
items: Array<any>
7-
keyExtractor?: (item: any) => string
7+
keyExtractor?: (item: any, idx: number) => string
88
renderItem: (index: number, item: any) => React.ReactElement
99
selectedIndex: number
1010
style?: Styles.StylesCrossPlatform

‎shared/chat/conversation/messages/message-popup/attachment/container.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,19 @@ export default Container.connect(
128128
path: [{props: {members: [username], teamID}, selected: 'teamReallyRemoveMember'}],
129129
})
130130
),
131-
_onPinMessage: (message: Types.Message) => {
131+
_onMarkAsUnread: (message: Types.Message) => {
132132
dispatch(
133-
Chat2Gen.createPinMessage({
133+
Chat2Gen.createMarkAsUnread({
134134
conversationIDKey: message.conversationIDKey,
135-
messageID: message.id,
135+
readMsgID: message.id,
136136
})
137137
)
138138
},
139-
_onMarkAsUnread: (message: Types.Message) => {
139+
_onPinMessage: (message: Types.Message) => {
140140
dispatch(
141-
Chat2Gen.createMarkAsUnread({
141+
Chat2Gen.createPinMessage({
142142
conversationIDKey: message.conversationIDKey,
143-
readMsgID: message.id,
143+
messageID: message.id,
144144
})
145145
)
146146
},
@@ -205,8 +205,8 @@ export default Container.connect(
205205
onHidden: () => ownProps.onHidden(),
206206
onInstallBot: stateProps._authorIsBot ? () => dispatchProps._onInstallBot(message) : undefined,
207207
onKick: () => dispatchProps._onKick(stateProps._teamID, message.author),
208-
onPinMessage: stateProps._canPinMessage ? () => dispatchProps._onPinMessage(message) : undefined,
209208
onMarkAsUnread: () => dispatchProps._onMarkAsUnread(message),
209+
onPinMessage: stateProps._canPinMessage ? () => dispatchProps._onPinMessage(message) : undefined,
210210
onReact: (emoji: string) => dispatchProps._onReact(message, emoji),
211211
onReply: () => dispatchProps._onReply(message),
212212
onSaveAttachment:

‎shared/chat/conversation/messages/message-popup/exploding/container.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,19 @@ export default Container.connect(
147147
path: [{props: {members: [username], teamID}, selected: 'teamReallyRemoveMember'}],
148148
})
149149
),
150-
_onPinMessage: (id: number) => {
150+
_onMarkAsUnread: (id: number) => {
151151
dispatch(
152-
Chat2Gen.createPinMessage({
152+
Chat2Gen.createMarkAsUnread({
153153
conversationIDKey: ownProps.conversationIDKey,
154-
messageID: id,
154+
readMsgID: id,
155155
})
156156
)
157157
},
158-
_onMarkAsUnread: (id: number) => {
158+
_onPinMessage: (id: number) => {
159159
dispatch(
160-
Chat2Gen.createMarkAsUnread({
160+
Chat2Gen.createPinMessage({
161161
conversationIDKey: ownProps.conversationIDKey,
162-
readMsgID: id,
162+
messageID: id,
163163
})
164164
)
165165
},

‎shared/chat/conversation/messages/message-popup/text/container.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,19 @@ export default Container.connect(
137137
path: [{props: {members: [username], teamID}, selected: 'teamReallyRemoveMember'}],
138138
})
139139
),
140-
_onPinMessage: (message: Types.Message) => {
140+
_onMarkAsUnread: (message: Types.Message) => {
141141
dispatch(
142-
Chat2Gen.createPinMessage({
142+
Chat2Gen.createMarkAsUnread({
143143
conversationIDKey: message.conversationIDKey,
144-
messageID: message.id,
144+
readMsgID: message.id,
145145
})
146146
)
147147
},
148-
_onMarkAsUnread: (message: Types.Message) => {
148+
_onPinMessage: (message: Types.Message) => {
149149
dispatch(
150-
Chat2Gen.createMarkAsUnread({
150+
Chat2Gen.createPinMessage({
151151
conversationIDKey: message.conversationIDKey,
152-
readMsgID: message.id,
152+
messageID: message.id,
153153
})
154154
)
155155
},
@@ -237,8 +237,8 @@ export default Container.connect(
237237
onHidden: () => ownProps.onHidden(),
238238
onInstallBot: stateProps._authorIsBot ? () => dispatchProps._onInstallBot(message) : undefined,
239239
onKick: () => dispatchProps._onKick(stateProps._teamID, message.author),
240-
onPinMessage: stateProps._canPinMessage ? () => dispatchProps._onPinMessage(message) : undefined,
241240
onMarkAsUnread: () => dispatchProps._onMarkAsUnread(message),
241+
onPinMessage: stateProps._canPinMessage ? () => dispatchProps._onPinMessage(message) : undefined,
242242
onReact: (emoji: string) => dispatchProps._onReact(message, emoji),
243243
onReply: message.type === 'text' ? () => dispatchProps._onReply(message) : undefined,
244244
onReplyPrivately:

‎shared/constants/chat2/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const makeState = (): Types.State => ({
9494
infoPanelSelectedTab: undefined,
9595
infoPanelShowing: false,
9696
lastCoord: undefined,
97+
markedAsUnreadMap: new Map(), // store a bit if we've marked this thread as unread so we don't mark as read when navgiating away
9798
maybeMentionMap: new Map(),
9899
messageCenterOrdinals: new Map(), // ordinals to center threads on,
99100
messageMap: new Map(), // messages in a thread,
@@ -104,7 +105,6 @@ export const makeState = (): Types.State => ({
104105
mutedMap: new Map(),
105106
mutualTeamMap: new Map(),
106107
orangeLineMap: new Map(), // last message we've seen,
107-
markedAsUnreadMap: new Map(), // store a bit if we've marked this thread as unread so we don't mark as read when navgiating away
108108
participantMap: new Map(),
109109
paymentConfirmInfo: undefined,
110110
paymentStatusMap: new Map(),

‎shared/teams/join-team/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const JoinTeam = (props: Props) => {
4747
<Kb.Modal
4848
banners={[
4949
!!props.errorText && (
50-
<Kb.Banner color="red">
50+
<Kb.Banner key="red" color="red">
5151
<Kb.BannerParagraph bannerColor="red" content={props.errorText} />
5252
</Kb.Banner>
5353
),

0 commit comments

Comments
 (0)