Skip to content

Commit

Permalink
refactor: hide conversation of member who left group
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-into committed Jun 6, 2024
1 parent 3976121 commit 2cfdadc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/screens/Mini/Chat/components/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ import { neutralA3, secondaryColor } from "@/utils/style/colors";
import { fontMedium13, fontSemibold14 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";
import { Conversation } from "@/utils/types/message";
import { weshConfig } from "@/weshnet";
import {
getConversationAvatar,
getConversationName,
} from "@/weshnet/messageHelpers";
import { stringFromBytes } from "@/weshnet/utils";

export const ChatList = () => {
const navigation = useAppNavigation();
const { activeConversationType, setActiveConversation } = useMessage();
const conversationList = useSelector((state: RootState) =>
selectFilteredConversationList(state, activeConversationType, ""),
);

const [searchInput, setSearchInput] = useState("");

const searchResults = useMemo(() => {
Expand Down Expand Up @@ -80,7 +81,12 @@ export const ChatList = () => {
data={searchResults.filter((result) => {
if (
result?.type === "group" &&
(!result?.members || result?.members.filter(Boolean).length === 0) // Hiding conversation from left member of the group
result.members?.find(
(member) =>
member?.id ===
stringFromBytes(weshConfig?.config?.accountPk) &&
!!member?.hasLeft,
) // Hiding conversation from member who left the group
) {
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/screens/Mini/Conversation/GroupActionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ const GroupActionScreen: ScreenFC<"MiniGroupActions"> = ({
const { setToast } = useFeedbacks();

const groupName = conversation && getConversationName(conversation);

const handleLeaveGroupPress = async () => {
if (conversation?.id) {
try {
await sendGroupLeaveMessage();
await weshClient.client.MultiMemberGroupLeave({
groupPk: bytesFromString(conversation.id),
});
await sendGroupLeaveMessage();
setToast({
mode: "mini",
message: `You left group ${groupName}`,
Expand Down

0 comments on commit 2cfdadc

Please sign in to comment.