mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-18 21:35:46 -04:00
committed by
GitHub
parent
62662e286b
commit
8df67b8992
@@ -776,4 +776,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 77ed9526d4011b245ce5afa1ea331dea4c67d753
|
||||
|
||||
COCOAPODS: 1.12.1
|
||||
COCOAPODS: 1.13.0
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import classnames from "classnames";
|
||||
import FlagItemModal from "components/ObsDetails/FlagItemModal";
|
||||
import {
|
||||
Body4, INatIcon, InlineUser, TextInputSheet
|
||||
Body4, INatIcon, InlineUser, TextInputSheet, WarningSheet
|
||||
} from "components/SharedComponents";
|
||||
import KebabMenu from "components/SharedComponents/KebabMenu";
|
||||
import {
|
||||
@@ -36,6 +36,7 @@ const ActivityHeader = ( {
|
||||
const [kebabMenuVisible, setKebabMenuVisible] = useState( false );
|
||||
const [flagModalVisible, setFlagModalVisible] = useState( false );
|
||||
const [showEditCommentSheet, setShowEditCommentSheet] = useState( false );
|
||||
const [showDeleteCommentSheet, setShowDeleteCommentSheet] = useState( false );
|
||||
const { user } = item;
|
||||
|
||||
const itemType = item.category
|
||||
@@ -145,7 +146,7 @@ const ActivityHeader = ( {
|
||||
/>
|
||||
<Menu.Item
|
||||
onPress={async ( ) => {
|
||||
deleteComment( item.uuid );
|
||||
setShowDeleteCommentSheet( true );
|
||||
setKebabMenuVisible( false );
|
||||
}}
|
||||
title={t( "Delete-comment" )}
|
||||
@@ -194,6 +195,17 @@ const ActivityHeader = ( {
|
||||
confirm={textInput => updateCommentBody( textInput )}
|
||||
/>
|
||||
)}
|
||||
{( currentUser && showDeleteCommentSheet ) && (
|
||||
<WarningSheet
|
||||
handleClose={( ) => setShowDeleteCommentSheet( false )}
|
||||
headerText={t( "DELETE-COMMENT" )}
|
||||
snapPoints={[148]}
|
||||
confirm={deleteComment}
|
||||
buttonText={t( "DELETE" )}
|
||||
handleSecondButtonPress={( ) => setShowDeleteCommentSheet( false )}
|
||||
secondButtonText={t( "CANCEL" )}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -4,16 +4,12 @@ import { useQueryClient } from "@tanstack/react-query";
|
||||
import { deleteComments, updateComment } from "api/comments";
|
||||
import { updateIdentification } from "api/identifications";
|
||||
import { isCurrentUser } from "components/LoginSignUp/AuthenticationService";
|
||||
import { RealmContext } from "providers/contexts";
|
||||
import type { Node } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Comment from "realmModels/Comment";
|
||||
import useAuthenticatedMutation from "sharedHooks/useAuthenticatedMutation";
|
||||
|
||||
import ActivityHeader from "./ActivityHeader";
|
||||
|
||||
const { useRealm } = RealmContext;
|
||||
|
||||
type Props = {
|
||||
item: Object,
|
||||
refetchRemoteObservation?: Function,
|
||||
@@ -28,7 +24,6 @@ const ActivityHeaderContainer = ( {
|
||||
}:Props ): Node => {
|
||||
const [currentUser, setCurrentUser] = useState( false );
|
||||
const [flagged, setFlagged] = useState( false );
|
||||
const realm = useRealm( );
|
||||
const queryClient = useQueryClient( );
|
||||
const { user } = item;
|
||||
|
||||
@@ -63,11 +58,7 @@ const ActivityHeaderContainer = ( {
|
||||
}
|
||||
);
|
||||
|
||||
const deleteUserComment = () => {
|
||||
Comment.deleteComment( item.uuid, realm );
|
||||
// then delete remotely
|
||||
deleteCommentMutation.mutate( item.uuid );
|
||||
};
|
||||
const deleteUserComment = ( ) => deleteCommentMutation.mutate( item.uuid );
|
||||
|
||||
const updateCommentMutation = useAuthenticatedMutation(
|
||||
( uuid, optsWithAuth ) => updateComment( uuid, optsWithAuth ),
|
||||
|
||||
@@ -234,6 +234,8 @@ DELETE = DELETE
|
||||
|
||||
DELETE-ALL = DELETE ALL
|
||||
|
||||
DELETE-COMMENT = DELETE COMMENT?
|
||||
|
||||
Delete-comment = Delete comment
|
||||
|
||||
DELETE-OBSERVATION = DELETE OBSERVATION?
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
"Default-Search-Place": "Default Search Place",
|
||||
"DELETE": "DELETE",
|
||||
"DELETE-ALL": "DELETE ALL",
|
||||
"DELETE-COMMENT": "DELETE COMMENT?",
|
||||
"Delete-comment": "Delete comment",
|
||||
"DELETE-OBSERVATION": "DELETE OBSERVATION?",
|
||||
"Delete-observation": "Delete observation",
|
||||
|
||||
@@ -234,6 +234,8 @@ DELETE = DELETE
|
||||
|
||||
DELETE-ALL = DELETE ALL
|
||||
|
||||
DELETE-COMMENT = DELETE COMMENT?
|
||||
|
||||
Delete-comment = Delete comment
|
||||
|
||||
DELETE-OBSERVATION = DELETE OBSERVATION?
|
||||
|
||||
@@ -20,13 +20,6 @@ class Comment extends Realm.Object {
|
||||
};
|
||||
}
|
||||
|
||||
static async deleteComment( id, realm ) {
|
||||
realm?.write( ( ) => {
|
||||
const commentToDelete = realm.objects( "Comment" ).filtered( `uuid == "${id}"` )[0];
|
||||
realm.delete( commentToDelete );
|
||||
} );
|
||||
}
|
||||
|
||||
static schema = {
|
||||
name: "Comment",
|
||||
properties: {
|
||||
|
||||
Reference in New Issue
Block a user