From f505f7819332c95db4361f8750d3093f69103457 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Sat, 25 Feb 2023 22:24:23 +0100 Subject: [PATCH] Update PrivateNotes.tsx --- .../Shared/Account/Information/PrivateNotes.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/screens/Tabs/Shared/Account/Information/PrivateNotes.tsx b/src/screens/Tabs/Shared/Account/Information/PrivateNotes.tsx index 6ac8aa19..41523cd8 100644 --- a/src/screens/Tabs/Shared/Account/Information/PrivateNotes.tsx +++ b/src/screens/Tabs/Shared/Account/Information/PrivateNotes.tsx @@ -14,7 +14,6 @@ import AccountContext from '../Context' const AccountInformationPrivateNote: React.FC = () => { const { relationship, pageMe } = useContext(AccountContext) - if (!relationship || pageMe) return null const { colors, mode } = useTheme() const { t } = useTranslation(['common', 'screenTabs']) @@ -22,14 +21,14 @@ const AccountInformationPrivateNote: React.FC = () => { const [editing, setEditing] = useState(false) const [notes, setNotes] = useState(relationship?.note) - const queryKey: QueryKeyRelationship = ['Relationship', { id: relationship.id }] + const queryKey: QueryKeyRelationship = ['Relationship', { id: relationship?.id }] const mutation = useRelationshipMutation({ onMutate: async vars => { await queryClient.cancelQueries({ queryKey }) queryClient.setQueryData(queryKey, old => { return old ? vars.type === 'note' - ? old.map(o => (o.id === relationship.id ? { ...o, note: notes } : o)) + ? old.map(o => (o.id === relationship?.id && notes ? { ...o, note: notes } : o)) : old : undefined }) @@ -39,11 +38,15 @@ const AccountInformationPrivateNote: React.FC = () => { } }) const submit = () => { - mutation.mutate({ id: relationship.id, type: 'note', payload: notes || '' }) - setEditing(!editing) - layoutAnimation() + if (relationship) { + mutation.mutate({ id: relationship.id, type: 'note', payload: notes || '' }) + setEditing(!editing) + layoutAnimation() + } } + if (!relationship || pageMe) return null + return relationship?.following ? ( editing ? (