diff --git a/src/components/dialogs/InviteDialog/InviteDialog.vue b/src/components/dialogs/InviteDialog/InviteDialog.vue index 59f5da89..3fc8ef41 100644 --- a/src/components/dialogs/InviteDialog/InviteDialog.vue +++ b/src/components/dialogs/InviteDialog/InviteDialog.vue @@ -25,14 +25,34 @@ @click="addFriendsInInstanceToInvite" >{{ t('dialog.invite.add_friends_in_instance') }} - + + + + + + + {{ group.displayName }} + + + + {{ group.displayName }} + + +
+ favoriteFriendGroups.value + .filter((group) => { + const favorites = groupedByGroupKeyFavoriteFriends.value[group.key]; + return favorites?.length && hasOnlineFriend(favorites.map((f) => f.id)); + }) + .map((group) => ({ + key: group.key, + displayName: group.displayName, + type: 'remote' + })) + ); + + const localFriendFavoriteGroupItems = computed(() => + localFriendFavoriteGroups.value + .filter((groupName) => { + const userIds = localFriendFavorites.value[groupName]; + return userIds?.length && hasOnlineFriend(userIds); + }) + .map((groupName) => ({ + key: `local:${groupName}`, + displayName: groupName, + type: 'local', + localName: groupName + })) + ); + + /** + * @param {object} group + */ + function addGroupOnlineFriendsToInvite(group) { const D = props.inviteDialog; - for (const friend of vipFriends.value) { - if (!D.userIds.includes(friend.id)) { - D.userIds.push(friend.id); + let userIds; + + if (group.type === 'remote') { + const favorites = groupedByGroupKeyFavoriteFriends.value[group.key] || []; + userIds = favorites.map((fav) => fav.id); + } else { + userIds = localFriendFavorites.value[group.localName] || []; + } + + for (const userId of userIds) { + const ctx = friends.value.get(userId); + if (ctx && ctx.state === 'online' && !D.userIds.includes(userId)) { + D.userIds.push(userId); } } }