diff --git a/src/lib/components/group/ViewMembers.svelte b/src/lib/components/group/ViewMembers.svelte index 3624c7ab0..266a0c83a 100644 --- a/src/lib/components/group/ViewMembers.svelte +++ b/src/lib/components/group/ViewMembers.svelte @@ -2,8 +2,7 @@ import { Appearance, Shape, Size } from "$lib/enums" import type { Chat, User } from "$lib/types" import ProfilePicture from "../profile/ProfilePicture.svelte" - import { Checkbox, Input, Text } from "$lib/elements" - import Controls from "$lib/layouts/Controls.svelte" + import { Checkbox, Text } from "$lib/elements" import Button from "$lib/elements/Button.svelte" import Icon from "$lib/elements/Icon.svelte" import Label from "$lib/elements/Label.svelte" @@ -20,37 +19,28 @@ let allRecipients: User[] = [] let friends: User[] = [] // Initialize friends as an empty array - function update_members(user: User) { - let group_members = [...members] - - if (group_members.includes(user)) { - group_members.splice(group_members.indexOf(user), 1) - } else { - group_members.push(user) - } - - members = group_members - RaygunStoreInstance.addGroupParticipants(activeChat.id, [user.key]) - } - - function remove_member(user: User) { - if (members.length < 3) { - Store.addToastNotification(new ToastMessage("", `A group can not exist with one person`, 2)) - return - } + function updateMembers(user: User) { if (user.key === activeChat.creator) { - Store.addToastNotification(new ToastMessage("", `You can not remove the group creator`, 2)) + Store.addToastNotification(new ToastMessage("", $_("chat.group.removeCreator"), 2)) + members = members return } + let groupMembers = [...members] - let group_members = [...members] - - if (group_members.includes(user)) { - group_members.splice(group_members.indexOf(user), 1) + if (groupMembers.includes(user)) { + if (members.length < 3) { + Store.addToastNotification(new ToastMessage("", $_("chat.group.removeTooSmall"), 2)) + members = members + return + } + groupMembers.splice(groupMembers.indexOf(user), 1) + RaygunStoreInstance.removeGroupParticipants(activeChat.id, [user.key]) + } else { + groupMembers.push(user) + RaygunStoreInstance.addGroupParticipants(activeChat.id, [user.key]) } - members = group_members - RaygunStoreInstance.removeGroupParticipants(activeChat.id, [user.key]) + members = groupMembers } function contains_user(list: User[], user: User): boolean { @@ -104,7 +94,7 @@ {recipient.name} - @@ -113,7 +103,7 @@