diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-08 18:42:28 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-04-08 18:42:28 -0400 |
commit | fab86f9b874524a4beabb3c45a9e59e8b00ca495 (patch) | |
tree | 8ab36bc222ac9f26c7c6ec57ac0bf8dc1bf6ed57 /src/utils | |
parent | bb16e95e15f6ea9b8941cae764570bdf7c0fdb59 (diff) |
added chat header, created isMember util, fixed KB padding issue
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/layouts.ts | 1 | ||||
-rw-r--r-- | src/utils/messages.ts | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/utils/layouts.ts b/src/utils/layouts.ts index e2f1f0b1..4d0d557d 100644 --- a/src/utils/layouts.ts +++ b/src/utils/layouts.ts @@ -31,6 +31,7 @@ export const StatusBarHeight = Platform.select({ }); export const AvatarHeaderHeight = (HeaderHeight + StatusBarHeight) * 1.3; +export const ChatHeaderHeight = (HeaderHeight + StatusBarHeight) * 1.1; /** * This is a function for normalizing the font size for different devices, based on iphone 8. diff --git a/src/utils/messages.ts b/src/utils/messages.ts index ae8e7cec..d63f2b7a 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -1,4 +1,6 @@ import moment from 'moment'; +import {RootState} from '../store/rootReducer'; +import {ChannelGroupedType} from '../types'; /** * Finds the difference in time in minutes @@ -57,3 +59,25 @@ export const isOnline = (lastActive: string | undefined) => { } return diff <= 15; }; + +/** + * Gets the other member in the channel. + * @param channel the current chat channel + * @param state the current redux state + * @returns other member or undefined + */ +export const getMember = ( + channel: ChannelGroupedType | undefined, + state: RootState, +) => { + if (!channel) { + return undefined; + } + const loggedInUserId = state.user.user.userId; + const otherMembers = channel + ? Object.values(channel.state.members).filter( + (member) => member.user?.id !== loggedInUserId, + ) + : []; + return otherMembers.length === 1 ? otherMembers[0] : undefined; +}; |