mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-06 10:50:13 +00:00
* bumps minSdkVersion to 30 Older versions are past end-of-life for security patches. voximplant service patch is also updated with minSdkVersion set to 30. * removes manifest attributes no longer needed when minSdk is 30 * removes guard to for version lower than O * removes permission check for versions lower than 28 * remove tests related to unsupported android sdk versions * bumps iOS minSdkVersion to 18 * removes iOS 13/15 guards in hardware-keyboard * removes iOS 15 guards in NotificationService * removes iOS 15 guard in Gekidou network delegate since gekidou is iOS only other platform guards are not needed * removes version guard no longer needed in voximplant patch * removes hasWriteStoragePermission dead stub and its call site * removes unused setSoftKeyboardToAdjustResize from rnutils The function had no call sites in JS/TS code and the iOS implementation was a no-op. * removes version guards and updates config after min version bump * updates stale iOS 17 simulator references in CI to iOS 18.1 Co-Authored-By: Carlos Garcia <carlos.garcia@mattermost.com> * fixes malformed patch file headers - voximplant patch: restore missing diff --git header and index line for VIForegroundServiceModule.java, fix stale hunk counter (+11 -> +7) - notifications patch: fix stale hunk line count (+91 -> +89) after KITKAT branch removal Co-Authored-By: Carlos Garcia <carlos.garcia@mattermost.com> * remove code below the supported OS versions * Bump IntuneMAM SDK to 21.8.0 and MSAL to 2.15.0 --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
177 lines
6.8 KiB
TypeScript
177 lines
6.8 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {BottomSheetScrollView} from '@gorhom/bottom-sheet';
|
|
import {useManagedConfig} from '@mattermost/react-native-emm';
|
|
import React, {useMemo} from 'react';
|
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
|
|
import {CopyPermalinkOption, FollowThreadOption, ReplyOption, SaveOption, ShowTranslationOption} from '@components/common_post_options';
|
|
import CopyTextOption from '@components/copy_text_option';
|
|
import {ITEM_HEIGHT} from '@components/option_item';
|
|
import {Screens} from '@constants';
|
|
import {REACTION_PICKER_HEIGHT, REACTION_PICKER_MARGIN} from '@constants/reaction_picker';
|
|
import BottomSheet from '@screens/bottom_sheet';
|
|
import BORReadReceipts, {BOR_READ_RECEIPTS_HEIGHT} from '@screens/post_options/bor_read_receipts';
|
|
import {isOwnBoRPost, isUnrevealedBoRPost} from '@utils/bor';
|
|
import {bottomSheetSnapPoint} from '@utils/helpers';
|
|
import {isSystemMessage} from '@utils/post';
|
|
|
|
import AppBindingsPostOptions from './options/app_bindings_post_option';
|
|
import DeletePostOption from './options/delete_post_option';
|
|
import EditOption from './options/edit_option';
|
|
import MarkAsUnreadOption from './options/mark_unread_option';
|
|
import PinChannelOption from './options/pin_channel_option';
|
|
import ReactionBar from './reaction_bar';
|
|
|
|
import type {BurnOnReadRecipientData} from '@typings/components/post_options';
|
|
import type PostModel from '@typings/database/models/servers/post';
|
|
import type ThreadModel from '@typings/database/models/servers/thread';
|
|
import type UserModel from '@typings/database/models/servers/user';
|
|
import type {AvailableScreens} from '@typings/screens/navigation';
|
|
|
|
type PostOptionsProps = {
|
|
canAddReaction: boolean;
|
|
canDelete: boolean;
|
|
canEdit: boolean;
|
|
canMarkAsUnread: boolean;
|
|
canPin: boolean;
|
|
canReply: boolean;
|
|
canViewTranslation: boolean;
|
|
combinedPost?: Post | PostModel;
|
|
isSaved: boolean;
|
|
sourceScreen: AvailableScreens;
|
|
post: PostModel;
|
|
thread?: ThreadModel;
|
|
bindings: AppBinding[];
|
|
serverUrl: string;
|
|
isBoRPost?: boolean;
|
|
showBoRReadReceipts?: boolean;
|
|
borReceiptData?: BurnOnReadRecipientData;
|
|
currentUser?: UserModel;
|
|
};
|
|
const PostOptions = ({
|
|
canAddReaction, canDelete, canEdit,
|
|
canMarkAsUnread, canPin, canReply, canViewTranslation,
|
|
combinedPost, isSaved,
|
|
sourceScreen, post, thread, bindings, serverUrl,
|
|
isBoRPost, showBoRReadReceipts, borReceiptData, currentUser,
|
|
}: PostOptionsProps) => {
|
|
const managedConfig = useManagedConfig<ManagedConfig>();
|
|
const {bottom} = useSafeAreaInsets();
|
|
const isSystemPost = isSystemMessage(post);
|
|
|
|
const canCopyBoRPostPermalink = isBoRPost ? post.userId === currentUser?.id : true;
|
|
const canCopyPermalink = !isSystemPost && managedConfig?.copyAndPasteProtection !== 'true' && canCopyBoRPostPermalink;
|
|
const canCopyText = canCopyPermalink && post.message && !isBoRPost;
|
|
|
|
const canSavePost = !isSystemPost && (!isUnrevealedBoRPost(post) || isOwnBoRPost(post, currentUser?.id));
|
|
|
|
const shouldRenderFollow = !(sourceScreen !== Screens.CHANNEL || !thread);
|
|
const shouldShowBindings = bindings.length > 0 && !isSystemPost;
|
|
|
|
const shouldShowBORReadReceipts = showBoRReadReceipts && borReceiptData;
|
|
|
|
const snapPoints = useMemo(() => {
|
|
const items: Array<string | number> = [1];
|
|
const optionsCount = [
|
|
canCopyPermalink, canCopyText, canDelete, canEdit,
|
|
canMarkAsUnread, canPin, canReply, canSavePost, shouldRenderFollow, canViewTranslation,
|
|
].reduce((acc, v) => {
|
|
return v ? acc + 1 : acc;
|
|
}, 0) + (shouldShowBindings ? 0.5 : 0);
|
|
|
|
items.push(
|
|
bottomSheetSnapPoint(optionsCount, ITEM_HEIGHT) +
|
|
(canAddReaction ? REACTION_PICKER_HEIGHT + REACTION_PICKER_MARGIN : 0) +
|
|
(shouldShowBORReadReceipts ? BOR_READ_RECEIPTS_HEIGHT : 0) + bottom,
|
|
);
|
|
|
|
if (shouldShowBindings) {
|
|
items.push('80%');
|
|
}
|
|
|
|
return items;
|
|
}, [canCopyPermalink, canCopyText, canDelete, canEdit, canMarkAsUnread, canPin, canReply, canSavePost, shouldRenderFollow, canViewTranslation, shouldShowBindings, canAddReaction, shouldShowBORReadReceipts, bottom]);
|
|
|
|
const renderContent = () => {
|
|
return (
|
|
<BottomSheetScrollView
|
|
bounces={false}
|
|
testID='post_options.scroll_view'
|
|
>
|
|
{shouldShowBORReadReceipts &&
|
|
<BORReadReceipts
|
|
totalReceipts={borReceiptData.totalRecipients}
|
|
readReceipts={borReceiptData.revealedCount}
|
|
/>
|
|
}
|
|
{canAddReaction && <ReactionBar postId={post.id}/>}
|
|
{canReply && <ReplyOption post={post}/>}
|
|
{shouldRenderFollow && <FollowThreadOption thread={thread}/>}
|
|
{canMarkAsUnread && !isSystemPost &&
|
|
<MarkAsUnreadOption
|
|
post={post}
|
|
sourceScreen={sourceScreen}
|
|
/>
|
|
}
|
|
{canCopyPermalink &&
|
|
<CopyPermalinkOption
|
|
post={post}
|
|
sourceScreen={sourceScreen}
|
|
/>
|
|
}
|
|
{canViewTranslation && <ShowTranslationOption postId={post.id}/>}
|
|
{canSavePost &&
|
|
<SaveOption
|
|
isSaved={isSaved}
|
|
postId={post.id}
|
|
/>
|
|
}
|
|
{Boolean(canCopyText && post.message) &&
|
|
<CopyTextOption
|
|
postMessage={post.messageSource || post.message}
|
|
sourceScreen={sourceScreen}
|
|
/>}
|
|
{canPin &&
|
|
<PinChannelOption
|
|
isPostPinned={post.isPinned}
|
|
postId={post.id}
|
|
/>
|
|
}
|
|
{canEdit &&
|
|
<EditOption
|
|
post={post}
|
|
canDelete={canDelete}
|
|
/>
|
|
}
|
|
{canDelete &&
|
|
<DeletePostOption
|
|
combinedPost={combinedPost}
|
|
post={post}
|
|
currentUser={currentUser}
|
|
/>}
|
|
{shouldShowBindings &&
|
|
<AppBindingsPostOptions
|
|
post={post}
|
|
serverUrl={serverUrl}
|
|
bindings={bindings}
|
|
/>
|
|
}
|
|
</BottomSheetScrollView>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<BottomSheet
|
|
renderContent={renderContent}
|
|
screen={Screens.POST_OPTIONS}
|
|
initialSnapIndex={1}
|
|
snapPoints={snapPoints}
|
|
testID='post_options'
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default React.memo(PostOptions);
|