Changeset View
Changeset View
Standalone View
Standalone View
native/chat/toggle-pin-modal.react.js
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | return { | ||||
'You may pin this message to the channel you are ' + | 'You may pin this message to the channel you are ' + | ||||
'currently viewing. To unpin a message, select the pinned messages ' + | 'currently viewing. To unpin a message, select the pinned messages ' + | ||||
'icon in the channel.', | 'icon in the channel.', | ||||
buttonText: 'Pin Message', | buttonText: 'Pin Message', | ||||
buttonStyle: styles.pinButton, | buttonStyle: styles.pinButton, | ||||
}; | }; | ||||
}, [isPinned, styles.pinButton, styles.removePinButton]); | }, [isPinned, styles.pinButton, styles.removePinButton]); | ||||
const modifiedItem = React.useMemo(() => { | |||||
// The if / else if / else conditional is for Flow | |||||
if (item.messageShapeType === 'robotext') { | |||||
return item; | |||||
} else if (item.messageShapeType === 'multimedia') { | |||||
return { | |||||
...item, | |||||
threadCreatedFromMessage: undefined, | |||||
reactions: {}, | |||||
startsConversation: false, | |||||
startsCluster: true, | |||||
endsCluster: true, | |||||
messageInfo: { | |||||
...item.messageInfo, | |||||
creator: { | |||||
...item.messageInfo.creator, | |||||
isViewer: false, | |||||
}, | |||||
}, | |||||
}; | |||||
} else { | |||||
return { | |||||
...item, | |||||
threadCreatedFromMessage: undefined, | |||||
reactions: {}, | |||||
startsConversation: false, | |||||
startsCluster: true, | |||||
endsCluster: true, | |||||
messageInfo: { | |||||
...item.messageInfo, | |||||
creator: { | |||||
...item.messageInfo.creator, | |||||
isViewer: false, | |||||
}, | |||||
}, | |||||
}; | |||||
} | |||||
}, [item]); | |||||
const createToggleMessagePinPromise = React.useCallback(async () => { | const createToggleMessagePinPromise = React.useCallback(async () => { | ||||
invariant(messageInfo.id, 'messageInfo.id should be defined'); | invariant(messageInfo.id, 'messageInfo.id should be defined'); | ||||
const result = await callToggleMessagePin({ | const result = await callToggleMessagePin({ | ||||
messageID: messageInfo.id, | messageID: messageInfo.id, | ||||
action: modalInfo.action, | action: modalInfo.action, | ||||
}); | }); | ||||
return { | return { | ||||
newMessageInfos: result.newMessageInfos, | newMessageInfos: result.newMessageInfos, | ||||
Show All 16 Lines | function TogglePinModal(props: TogglePinModalProps): React.Node { | ||||
return ( | return ( | ||||
<Modal modalStyle={styles.modal}> | <Modal modalStyle={styles.modal}> | ||||
<Text style={styles.modalHeader}>{modalInfo.name}</Text> | <Text style={styles.modalHeader}>{modalInfo.name}</Text> | ||||
<Text style={styles.modalConfirmationText}> | <Text style={styles.modalConfirmationText}> | ||||
{modalInfo.confirmationText} | {modalInfo.confirmationText} | ||||
</Text> | </Text> | ||||
<MessageResult | <MessageResult | ||||
item={modifiedItem} | item={item} | ||||
threadInfo={threadInfo} | threadInfo={threadInfo} | ||||
navigation={navigation} | navigation={navigation} | ||||
route={route} | route={route} | ||||
messageVerticalBounds={null} | messageVerticalBounds={null} | ||||
/> | /> | ||||
<View style={styles.buttonsContainer}> | <View style={styles.buttonsContainer}> | ||||
<Button style={modalInfo.buttonStyle} onPress={onPress}> | <Button style={modalInfo.buttonStyle} onPress={onPress}> | ||||
<Text style={styles.textColor}>{modalInfo.buttonText}</Text> | <Text style={styles.textColor}>{modalInfo.buttonText}</Text> | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |