feat: add message pinned icon (#5598)
* feat: add message pinned icon * fix: add pinned to user * test: add e2e * test: updates tests * test: update storyshot * update tests * update snapshot * fix: update color --------- Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
224c054b04
commit
c42d196b15
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,11 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { CustomIcon } from '../../../CustomIcon';
|
||||||
|
import styles from '../../styles';
|
||||||
|
|
||||||
|
const Pinned = ({ pinned, testID }: { pinned?: boolean; testID?: string }): React.ReactElement | null => {
|
||||||
|
if (pinned) return <CustomIcon testID={testID} name='pin' size={16} style={styles.rightIcons} />;
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Pinned;
|
|
@ -1,12 +1,13 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StyleSheet, View } from 'react-native';
|
import { StyleSheet, View } from 'react-native';
|
||||||
|
|
||||||
import Encrypted from './Encrypted';
|
import { MessageType } from '../../../../definitions';
|
||||||
import Edited from './Edited';
|
import Edited from './Edited';
|
||||||
|
import Encrypted from './Encrypted';
|
||||||
import MessageError from './MessageError';
|
import MessageError from './MessageError';
|
||||||
|
import Pinned from './Pinned';
|
||||||
import ReadReceipt from './ReadReceipt';
|
import ReadReceipt from './ReadReceipt';
|
||||||
import Translated from './Translated';
|
import Translated from './Translated';
|
||||||
import { MessageType } from '../../../../definitions';
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
actionIcons: {
|
actionIcons: {
|
||||||
|
@ -22,10 +23,21 @@ interface IRightIcons {
|
||||||
unread?: boolean;
|
unread?: boolean;
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
isTranslated: boolean;
|
isTranslated: boolean;
|
||||||
|
pinned?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RightIcons = ({ type, msg, isEdited, hasError, isReadReceiptEnabled, unread, isTranslated }: IRightIcons) => (
|
const RightIcons = ({
|
||||||
|
type,
|
||||||
|
msg,
|
||||||
|
isEdited,
|
||||||
|
hasError,
|
||||||
|
isReadReceiptEnabled,
|
||||||
|
unread,
|
||||||
|
isTranslated,
|
||||||
|
pinned
|
||||||
|
}: IRightIcons): React.ReactElement => (
|
||||||
<View style={styles.actionIcons}>
|
<View style={styles.actionIcons}>
|
||||||
|
<Pinned pinned={pinned} testID={`${msg}-pinned`} />
|
||||||
<Encrypted type={type} />
|
<Encrypted type={type} />
|
||||||
<Edited testID={`${msg}-edited`} isEdited={isEdited} />
|
<Edited testID={`${msg}-edited`} isEdited={isEdited} />
|
||||||
<MessageError hasError={hasError} />
|
<MessageError hasError={hasError} />
|
||||||
|
|
|
@ -127,6 +127,13 @@ export const Edited = () => (
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const Pinned = () => (
|
||||||
|
<>
|
||||||
|
<Message msg='Message header' pinned />
|
||||||
|
<Message msg='Message without header' pinned isHeader={false} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
export const Translated = () => (
|
export const Translated = () => (
|
||||||
<>
|
<>
|
||||||
<Message msg='Message header' isTranslated />
|
<Message msg='Message header' isTranslated />
|
||||||
|
|
|
@ -117,6 +117,7 @@ const Message = React.memo((props: IMessage) => {
|
||||||
hasError={props.hasError}
|
hasError={props.hasError}
|
||||||
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
||||||
unread={props.unread}
|
unread={props.unread}
|
||||||
|
pinned={props.pinned}
|
||||||
isTranslated={props.isTranslated}
|
isTranslated={props.isTranslated}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
|
@ -60,6 +60,7 @@ interface IMessageUser {
|
||||||
isEdited: boolean;
|
isEdited: boolean;
|
||||||
isReadReceiptEnabled?: boolean;
|
isReadReceiptEnabled?: boolean;
|
||||||
unread?: boolean;
|
unread?: boolean;
|
||||||
|
pinned?: boolean;
|
||||||
isTranslated: boolean;
|
isTranslated: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ const User = React.memo(
|
||||||
hasError={hasError}
|
hasError={hasError}
|
||||||
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
||||||
unread={props.unread}
|
unread={props.unread}
|
||||||
|
pinned={props.pinned}
|
||||||
isTranslated={isTranslated}
|
isTranslated={isTranslated}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -390,7 +390,8 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
|
||||||
autoTranslate: autoTranslateMessage,
|
autoTranslate: autoTranslateMessage,
|
||||||
replies,
|
replies,
|
||||||
md,
|
md,
|
||||||
comment
|
comment,
|
||||||
|
pinned
|
||||||
} = item;
|
} = item;
|
||||||
|
|
||||||
let message = msg;
|
let message = msg;
|
||||||
|
@ -485,6 +486,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
|
||||||
isTranslated={isTranslated}
|
isTranslated={isTranslated}
|
||||||
isBeingEdited={isBeingEdited}
|
isBeingEdited={isBeingEdited}
|
||||||
isPreview={isPreview}
|
isPreview={isPreview}
|
||||||
|
pinned={pinned}
|
||||||
/>
|
/>
|
||||||
</MessageContext.Provider>
|
</MessageContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -64,6 +64,7 @@ export interface IMessageContent {
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
isHeader: boolean;
|
isHeader: boolean;
|
||||||
isTranslated: boolean;
|
isTranslated: boolean;
|
||||||
|
pinned?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMessageEmoji {
|
export interface IMessageEmoji {
|
||||||
|
|
|
@ -194,7 +194,10 @@ describe('Room actions screen', () => {
|
||||||
|
|
||||||
// Pin the message
|
// Pin the message
|
||||||
await pinMessage(messageToPin);
|
await pinMessage(messageToPin);
|
||||||
|
// verify pin icon
|
||||||
|
await waitFor(element(by.id(`${messageToPin}-pinned`)))
|
||||||
|
.toExist()
|
||||||
|
.withTimeout(6000);
|
||||||
// Back into Room Actions
|
// Back into Room Actions
|
||||||
await element(by.id('room-header')).tap();
|
await element(by.id('room-header')).tap();
|
||||||
await waitFor(element(by.id('room-actions-view')))
|
await waitFor(element(by.id('room-actions-view')))
|
||||||
|
@ -220,6 +223,10 @@ describe('Room actions screen', () => {
|
||||||
await waitFor(element(by[textMatcher](messageToPin).withAncestor(by.id('pinned-messages-view'))))
|
await waitFor(element(by[textMatcher](messageToPin).withAncestor(by.id('pinned-messages-view'))))
|
||||||
.not.toExist()
|
.not.toExist()
|
||||||
.withTimeout(6000);
|
.withTimeout(6000);
|
||||||
|
// verify pin icon
|
||||||
|
await waitFor(element(by.id(`${messageToPin}-pinned`)))
|
||||||
|
.not.toExist()
|
||||||
|
.withTimeout(6000);
|
||||||
await backToActions();
|
await backToActions();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue