Enable adding friends to multiple local favorite groups and update instance activity charts to include all favorite friends.

This commit is contained in:
pa
2026-02-14 18:00:42 +09:00
parent 4e552bf3b9
commit ad3346427f
5 changed files with 34 additions and 35 deletions

View File

@@ -32,22 +32,18 @@
</div>
<div v-if="favoriteDialog.type === 'friend'" style="margin-top: 20px">
<span style="display: block; text-align: center">{{ t('dialog.favorite.local_favorites') }}</span>
<template v-if="currentLocalFriendGroup">
<template v-for="group in localFriendFavoriteGroups" :key="group">
<Button
variant="outline"
v-if="hasLocalFriendFavorite(favoriteDialog.objectId, group)"
style="width: 100%; white-space: initial"
class="my-1"
@click="removeLocalFriendFavorite(favoriteDialog.objectId, currentLocalFriendGroup)">
<Check />{{ currentLocalFriendGroup }} ({{
localFriendFavGroupLength(currentLocalFriendGroup)
}})
@click="removeLocalFriendFavorite(favoriteDialog.objectId, group)">
<Check />{{ group }} ({{ localFriendFavGroupLength(group) }})
</Button>
</template>
<template v-else>
<Button
variant="outline"
v-for="group in localFriendFavoriteGroups"
:key="group"
v-else
style="width: 100%; white-space: initial"
class="my-1"
@click="addLocalFriendFavorite(favoriteDialog.objectId, group)">
@@ -154,16 +150,6 @@
}
});
const currentLocalFriendGroup = computed(() => {
const objectId = favoriteDialog.value.objectId;
for (const group of localFriendFavoriteGroups.value) {
if (hasLocalFriendFavorite(objectId, group)) {
return group;
}
}
return null;
});
watch(
() => favoriteDialog.value.visible,
(value) => {

View File

@@ -538,8 +538,8 @@
"auto_change_status": "Auto Change Status",
"auto_state_change_tooltip": "Automatically change status when there are other people in the instance (Alone / Company)",
"alone_condition": "Consider alone when",
"alone": "No other players",
"no_friends": "No friends in instance",
"alone": "No other user",
"no_friends": "No friend in instance",
"alone_status": "Alone Status",
"company_status": "Company Status",
"allowed_instance_types": "Active in instance types",

View File

@@ -1536,15 +1536,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
if (hasLocalFriendFavorite(userId, group)) {
return;
}
for (const existingGroup in localFriendFavorites) {
const members = localFriendFavorites[existingGroup];
const idx = members?.indexOf(userId);
if (idx !== undefined && idx !== -1) {
members.splice(idx, 1);
database.removeFriendFromLocalFavorites(userId, existingGroup);
break;
}
}
if (!localFriendFavorites[group]) {
localFriendFavorites[group] = [];
}

View File

@@ -186,8 +186,8 @@
import BackToTop from '@/components/BackToTop.vue';
import dayjs from 'dayjs';
import { useAppearanceSettingsStore, useFavoriteStore, useFriendStore, useUserStore } from '../../../stores';
import { Popover, PopoverContent, PopoverTrigger } from '../../../components/ui/popover';
import { useAppearanceSettingsStore, useFriendStore, useUserStore } from '../../../stores';
import { parseLocation, timeToText } from '../../../shared/utils';
import { Slider } from '../../../components/ui/slider';
import { Switch } from '../../../components/ui/switch';
@@ -204,11 +204,32 @@
const appearanceSettingsStore = useAppearanceSettingsStore();
const friendStore = useFriendStore();
const favoriteStore = useFavoriteStore();
const { isDarkMode, dtHour12 } = storeToRefs(appearanceSettingsStore);
const { localFavoriteFriends, friends } = storeToRefs(friendStore);
const { friends } = storeToRefs(friendStore);
const { cachedFavorites, localFriendFavorites } = storeToRefs(favoriteStore);
const { currentUser } = storeToRefs(useUserStore());
const { t } = useI18n();
// All favorite friends (remote + local)
const allFavoriteFriends = computed(() => {
const set = new Set();
for (const ref of cachedFavorites.value.values()) {
if (ref.type === 'friend') {
set.add(ref.favoriteId);
}
}
for (const group in localFriendFavorites.value) {
const userIds = localFriendFavorites.value[group];
if (userIds) {
for (const id of userIds) {
set.add(id);
}
}
}
return set;
});
const instanceActivityRef = ref(null);
const instanceActivityResizeObserver = new ResizeObserver(() => {
@@ -373,7 +394,7 @@
onMounted(async () => {
try {
getAllDateOfActivity();
await getActivityData(selectedDate, currentUser, friends, localFavoriteFriends, () =>
await getActivityData(selectedDate, currentUser, friends, allFavoriteFriends, () =>
handleIntersectionObserver(activityDetailChartRef)
);
await getWorldNameData();
@@ -398,7 +419,7 @@
reloadData = async function () {
isLoading.value = true;
try {
await getActivityData(selectedDate, currentUser, friends, localFavoriteFriends, () =>
await getActivityData(selectedDate, currentUser, friends, allFavoriteFriends, () =>
handleIntersectionObserver(activityDetailChartRef)
);
await getWorldNameData();

View File

@@ -63,7 +63,8 @@ export function useInstanceActivityData() {
isFriend:
item.user_id === currentUser.value.id
? null
: friends.value.has(item.user_id),
: friends.value.has(item.user_id) ||
localFavoriteFriends.value.has(item.user_id),
isFavorite:
item.user_id === currentUser.value.id
? null