diff --git a/app/screens/post_options/components/options/copy_link_option.tsx b/app/screens/post_options/components/options/copy_link_option.tsx
deleted file mode 100644
index c4cc538e7..000000000
--- a/app/screens/post_options/components/options/copy_link_option.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See LICENSE.txt for license information.
-
-import React from 'react';
-
-import {t} from '@i18n';
-
-import BaseOption from './base_option';
-
-const CopyPermalinkOption = () => {
- const handleCopyLink = () => {
- //todo:
- };
- return (
-
- );
-};
-
-export default CopyPermalinkOption;
diff --git a/app/screens/post_options/components/options/copy_permalink_option/copy_permalink_option.tsx b/app/screens/post_options/components/options/copy_permalink_option/copy_permalink_option.tsx
new file mode 100644
index 000000000..47d9a3142
--- /dev/null
+++ b/app/screens/post_options/components/options/copy_permalink_option/copy_permalink_option.tsx
@@ -0,0 +1,40 @@
+// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
+// See LICENSE.txt for license information.
+
+import Clipboard from '@react-native-community/clipboard';
+import React, {useCallback} from 'react';
+
+import {Screens} from '@constants';
+import {useServerUrl} from '@context/server';
+import {t} from '@i18n';
+import {dismissBottomSheet} from '@screens/navigation';
+
+import BaseOption from '../base_option';
+
+import type PostModel from '@typings/database/models/servers/post';
+
+type Props = {
+ teamName: string;
+ post: PostModel;
+}
+const CopyPermalinkOption = ({teamName, post}: Props) => {
+ const serverUrl = useServerUrl();
+
+ const handleCopyLink = useCallback(() => {
+ const permalink = `${serverUrl}/${teamName}/pl/${post.id}`;
+ Clipboard.setString(permalink);
+ dismissBottomSheet(Screens.POST_OPTIONS);
+ }, [teamName, post.id]);
+
+ return (
+
+ );
+};
+
+export default CopyPermalinkOption;
diff --git a/app/screens/post_options/components/options/copy_permalink_option/index.tsx b/app/screens/post_options/components/options/copy_permalink_option/index.tsx
new file mode 100644
index 000000000..9c7f992f0
--- /dev/null
+++ b/app/screens/post_options/components/options/copy_permalink_option/index.tsx
@@ -0,0 +1,43 @@
+// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
+// See LICENSE.txt for license information.
+
+import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
+import withObservables from '@nozbe/with-observables';
+import {combineLatest, of as of$} from 'rxjs';
+import {switchMap} from 'rxjs/dist/types/operators';
+
+import {MM_TABLES, SYSTEM_IDENTIFIERS} from '@constants/database';
+
+import CopyPermalinkOption from './copy_permalink_option';
+
+import type {WithDatabaseArgs} from '@typings/database/database';
+import type PostModel from '@typings/database/models/servers/post';
+import type SystemModel from '@typings/database/models/servers/system';
+import type TeamModel from '@typings/database/models/servers/team';
+
+const {SERVER: {SYSTEM, TEAM}} = MM_TABLES;
+const {CURRENT_TEAM_ID} = SYSTEM_IDENTIFIERS;
+
+const enhanced = withObservables(['post'], ({post, database}: WithDatabaseArgs & { post: PostModel }) => {
+ const currentTeamId = database.get(SYSTEM).findAndObserve(CURRENT_TEAM_ID);
+ const channel = post.channel.observe();
+
+ const teamName = combineLatest([channel, currentTeamId]).pipe(
+ switchMap(([c, tid]) => {
+ const teamId = c.teamId || tid;
+ return database.
+ get(TEAM).
+ findAndObserve(teamId).
+ pipe(
+ // eslint-disable-next-line max-nested-callbacks
+ switchMap((team: TeamModel) => of$(team.name)),
+ );
+ }),
+ );
+
+ return {
+ teamName,
+ };
+});
+
+export default withDatabase(enhanced(CopyPermalinkOption));
diff --git a/app/screens/post_options/components/options/copy_text_option.tsx b/app/screens/post_options/components/options/copy_text_option.tsx
index b9db26ad1..81acc2bc2 100644
--- a/app/screens/post_options/components/options/copy_text_option.tsx
+++ b/app/screens/post_options/components/options/copy_text_option.tsx
@@ -1,16 +1,24 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import React from 'react';
+import Clipboard from '@react-native-community/clipboard';
+import React, {useCallback} from 'react';
+import {Screens} from '@constants';
import {t} from '@i18n';
+import {dismissBottomSheet} from '@screens/navigation';
import BaseOption from './base_option';
-const CopyTextOption = () => {
- const handleCopyText = () => {
- //todo:
- };
+type Props = {
+ postMessage: string;
+}
+const CopyTextOption = ({postMessage}: Props) => {
+ const handleCopyText = useCallback(() => {
+ Clipboard.setString(postMessage);
+ dismissBottomSheet(Screens.POST_OPTIONS);
+ }, [postMessage]);
+
return (
}
{canMarkAsUnread && !isSystemPost && ()}
- {canCopyPermalink && }
+ {canCopyPermalink && }
{!isSystemPost && }
- {canCopyText && }
+ {canCopyText && }
{canPin && }
{canEdit && }
{canDelete && }