about summary refs log tree commit diff
path: root/src/view/com/util/DropdownBtn.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-11-16 16:16:43 -0600
committerPaul Frazee <pfrazee@gmail.com>2022-11-16 16:16:43 -0600
commit41ae87e770f23ebe5ad02dbc68a497e0fb2f2a3d (patch)
tree0bba2afc4eaa19abe64fafeaf2e6ac50861cae15 /src/view/com/util/DropdownBtn.tsx
parentbd1a4b198e3682f96354d83f1e1efccf31813f82 (diff)
downloadvoidsky-41ae87e770f23ebe5ad02dbc68a497e0fb2f2a3d.tar.zst
Add post deletion
Diffstat (limited to 'src/view/com/util/DropdownBtn.tsx')
-rw-r--r--src/view/com/util/DropdownBtn.tsx23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/view/com/util/DropdownBtn.tsx b/src/view/com/util/DropdownBtn.tsx
index 960293320..bef193f1d 100644
--- a/src/view/com/util/DropdownBtn.tsx
+++ b/src/view/com/util/DropdownBtn.tsx
@@ -13,7 +13,7 @@ import RootSiblings from 'react-native-root-siblings'
 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
 import {colors} from '../../lib/styles'
 import {useStores} from '../../../state'
-import {SharePostModel} from '../../../state/models/shell-ui'
+import {SharePostModel, ConfirmModel} from '../../../state/models/shell-ui'
 
 export interface DropdownItem {
   icon?: IconProp
@@ -69,11 +69,15 @@ export function PostDropdownBtn({
   children,
   itemHref,
   itemTitle,
+  isAuthor,
+  onDeletePost,
 }: {
   style?: StyleProp<ViewStyle>
   children?: React.ReactNode
   itemHref: string
   itemTitle: string
+  isAuthor: boolean
+  onDeletePost: () => void
 }) {
   const store = useStores()
 
@@ -92,7 +96,22 @@ export function PostDropdownBtn({
         store.shell.openModal(new SharePostModel(itemHref))
       },
     },
-  ]
+    isAuthor
+      ? {
+          icon: ['far', 'trash-can'],
+          label: 'Delete post',
+          onPress() {
+            store.shell.openModal(
+              new ConfirmModel(
+                'Delete this post?',
+                'Are you sure? This can not be undone.',
+                onDeletePost,
+              ),
+            )
+          },
+        }
+      : undefined,
+  ].filter(Boolean) as DropdownItem[]
 
   return (
     <DropdownBtn style={style} items={dropdownItems} menuWidth={200}>