-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: more chat fixes + message status + optimistic update for text message + refactor queries/mutations #1357
Changes from all commits
c36902a
26b8bc3
88d2de8
9cc58a2
232f07d
8468ff7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||||||||||
import { useGroupName } from "@/hooks/useGroupName"; | ||||||||||||
import { useCurrentAccount } from "@data/store/accountsStore"; | ||||||||||||
import { useGroupMembers } from "@hooks/useGroupMembers"; | ||||||||||||
import { useGroupName } from "@hooks/useGroupName"; | ||||||||||||
import { useGroupPermissions } from "@hooks/useGroupPermissions"; | ||||||||||||
import { textPrimaryColor } from "@styles/colors"; | ||||||||||||
import { | ||||||||||||
|
@@ -13,12 +13,12 @@ import { formatGroupName } from "@utils/str"; | |||||||||||
import type { ConversationTopic } from "@xmtp/react-native-sdk"; | ||||||||||||
import React, { FC, useCallback, useMemo, useState } from "react"; | ||||||||||||
import { | ||||||||||||
Alert, | ||||||||||||
Pressable, | ||||||||||||
StyleSheet, | ||||||||||||
Text, | ||||||||||||
TextInput, | ||||||||||||
useColorScheme, | ||||||||||||
Text, | ||||||||||||
Alert, | ||||||||||||
Pressable, | ||||||||||||
} from "react-native"; | ||||||||||||
|
||||||||||||
type GroupScreenNameProps = { | ||||||||||||
|
@@ -28,9 +28,9 @@ type GroupScreenNameProps = { | |||||||||||
export const GroupScreenName: FC<GroupScreenNameProps> = ({ topic }) => { | ||||||||||||
const styles = useStyles(); | ||||||||||||
const { permissions } = useGroupPermissions(topic); | ||||||||||||
const { groupName, setGroupName } = useGroupName(topic); | ||||||||||||
const currentAccount = useCurrentAccount()!; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider safer type handling for currentAccount. The non-null assertion ( -const currentAccount = useCurrentAccount()!;
+const currentAccount = useCurrentAccount();
+if (!currentAccount) {
+ return null; // or handle the case appropriately
+} 📝 Committable suggestion
Suggested change
|
||||||||||||
const { updateGroupName, groupName } = useGroupName(topic); | ||||||||||||
const formattedGroupName = formatGroupName(topic, groupName); | ||||||||||||
const currentAccount = useCurrentAccount() as string; | ||||||||||||
const { members } = useGroupMembers(topic); | ||||||||||||
|
||||||||||||
const { currentAccountIsAdmin, currentAccountIsSuperAdmin } = useMemo( | ||||||||||||
|
@@ -49,12 +49,12 @@ export const GroupScreenName: FC<GroupScreenNameProps> = ({ topic }) => { | |||||||||||
const handleNameChange = useCallback(async () => { | ||||||||||||
try { | ||||||||||||
setEditing(false); | ||||||||||||
await setGroupName(editedName); | ||||||||||||
await updateGroupName(editedName); | ||||||||||||
} catch (e) { | ||||||||||||
logger.error(e); | ||||||||||||
Alert.alert("An error occurred"); | ||||||||||||
} | ||||||||||||
}, [editedName, setGroupName]); | ||||||||||||
}, [editedName, updateGroupName]); | ||||||||||||
const canEditGroupName = memberCanUpdateGroup( | ||||||||||||
permissions?.updateGroupNamePolicy, | ||||||||||||
currentAccountIsAdmin, | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling for missing peerInboxId.
The hook usage should handle cases where peerInboxId data is undefined.