Fix unfavoriting

This commit is contained in:
Natsumi
2025-11-01 16:38:36 +11:00
parent 447ff3ce20
commit 23b7c45951
5 changed files with 33 additions and 51 deletions
+1
View File
@@ -208,6 +208,7 @@ const miscReq = {
method: 'POST', method: 'POST',
params: { params: {
emojiId: params.emojiId emojiId: params.emojiId
// inventoryItemId
} }
}).then((json) => { }).then((json) => {
const args = { const args = {
+20 -40
View File
@@ -291,19 +291,11 @@ export const useFavoriteStore = defineStore('Favorite', () => {
if (typeof ref === 'undefined') { if (typeof ref === 'undefined') {
return; return;
} }
friendStore.localFavoriteFriends.delete(args.params.objectId); // if (ref.$isDeleted) {
friendStore.updateSidebarFriendsList(); // return;
if (ref.$isDeleted) { // }
return;
}
args.ref = ref; args.ref = ref;
ref.$isDeleted = true; handleFavoriteAtDelete(ref);
handleFavoriteAtDelete({
ref,
params: {
favoriteId: ref.id
}
});
} }
function handleFavoriteGroup(args) { function handleFavoriteGroup(args) {
@@ -320,15 +312,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
if (ref.$isDeleted || ref.$groupKey !== key) { if (ref.$isDeleted || ref.$groupKey !== key) {
continue; continue;
} }
friendStore.localFavoriteFriends.delete(ref.favoriteId); handleFavoriteAtDelete(ref);
friendStore.updateSidebarFriendsList();
ref.$isDeleted = true;
handleFavoriteAtDelete({
ref,
params: {
favoriteId: ref.id
}
});
} }
} }
@@ -359,15 +343,16 @@ export const useFavoriteStore = defineStore('Favorite', () => {
state.favoriteAvatars_ = []; state.favoriteAvatars_ = [];
} }
function handleFavoriteAtDelete(args) { function handleFavoriteAtDelete(ref) {
applyFavorite(args.ref.type, args.ref.favoriteId); ref.$isDeleted = true;
friendStore.updateFriend(args.ref.favoriteId); cachedFavorites.delete(ref.id);
friendStore.localFavoriteFriends.delete(ref.favoriteId);
applyFavorite(ref.type, ref.favoriteId);
friendStore.updateFriend(ref.favoriteId);
friendStore.updateSidebarFavorites();
const userDialog = userStore.userDialog; const userDialog = userStore.userDialog;
if ( if (
!( !(userDialog.visible === false || userDialog.id !== ref.favoriteId)
userDialog.visible === false ||
userDialog.id !== args.ref.favoriteId
)
) { ) {
userDialog.isFavorite = false; userDialog.isFavorite = false;
} }
@@ -376,7 +361,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
if ( if (
!( !(
worldDialog.visible === false || worldDialog.visible === false ||
worldDialog.id !== args.ref.favoriteId worldDialog.id !== ref.favoriteId
) )
) { ) {
worldDialog.isFavorite = localWorldFavoritesList.value.includes( worldDialog.isFavorite = localWorldFavoritesList.value.includes(
@@ -388,7 +373,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
if ( if (
!( !(
avatarDialog.visible === false || avatarDialog.visible === false ||
avatarDialog.id !== args.ref.favoriteId avatarDialog.id !== ref.favoriteId
) )
) { ) {
avatarDialog.isFavorite = false; avatarDialog.isFavorite = false;
@@ -534,7 +519,8 @@ export const useFavoriteStore = defineStore('Favorite', () => {
state.favoriteAvatars_.push(ctx); state.favoriteAvatars_.push(ctx);
} }
} }
} else if (typeof ctx !== 'undefined') { }
if (typeof favorite === 'undefined' && typeof ctx !== 'undefined') {
state.favoriteObjects.delete(objectId); state.favoriteObjects.delete(objectId);
if (type === 'friend') { if (type === 'friend') {
removeFromArray(state.favoriteFriends_, ctx); removeFromArray(state.favoriteFriends_, ctx);
@@ -817,7 +803,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
)) ))
) { ) {
friendStore.localFavoriteFriends.add(ref.favoriteId); friendStore.localFavoriteFriends.add(ref.favoriteId);
friendStore.updateSidebarFriendsList(); friendStore.updateSidebarFavorites();
} }
} else { } else {
Object.assign(ref, json); Object.assign(ref, json);
@@ -839,16 +825,10 @@ export const useFavoriteStore = defineStore('Favorite', () => {
*/ */
function deleteExpiredFavorites() { function deleteExpiredFavorites() {
for (const ref of cachedFavorites.values()) { for (const ref of cachedFavorites.values()) {
if (ref.$isDeleted || ref.$isExpired === false) { if (ref.$isDeleted || !ref.$isExpired) {
continue; continue;
} }
ref.$isDeleted = true; handleFavoriteAtDelete(ref);
handleFavoriteAtDelete({
ref,
params: {
favoriteId: ref.id
}
});
} }
} }
+8 -8
View File
@@ -200,7 +200,7 @@ export const useFriendStore = defineStore('Friend', () => {
() => watchState.isFriendsLoaded, () => watchState.isFriendsLoaded,
(isFriendsLoaded) => { (isFriendsLoaded) => {
if (isFriendsLoaded) { if (isFriendsLoaded) {
updateOnlineFriendCoutner(); updateOnlineFriendCounter();
} }
}, },
{ flush: 'sync' } { flush: 'sync' }
@@ -219,7 +219,7 @@ export const useFriendStore = defineStore('Friend', () => {
if (watchState.isFriendsLoaded) { if (watchState.isFriendsLoaded) {
refreshFriendsStatus(ref); refreshFriendsStatus(ref);
} }
updateOnlineFriendCoutner(); updateOnlineFriendCounter();
if (appearanceSettingsStore.randomUserColours) { if (appearanceSettingsStore.randomUserColours) {
getNameColour(userStore.currentUser.id).then((colour) => { getNameColour(userStore.currentUser.id).then((colour) => {
@@ -300,10 +300,10 @@ export const useFriendStore = defineStore('Friend', () => {
localFavoriteFriends.add(ref.favoriteId); localFavoriteFriends.add(ref.favoriteId);
} }
} }
updateSidebarFriendsList(); updateSidebarFavorites();
} }
function updateSidebarFriendsList() { function updateSidebarFavorites() {
for (const ctx of friends.values()) { for (const ctx of friends.values()) {
const isVIP = localFavoriteFriends.has(ctx.id); const isVIP = localFavoriteFriends.has(ctx.id);
if (ctx.isVIP === isVIP) { if (ctx.isVIP === isVIP) {
@@ -548,7 +548,7 @@ export const useFriendStore = defineStore('Friend', () => {
} }
if (ctx.state !== newState) { if (ctx.state !== newState) {
ctx.state = newState; ctx.state = newState;
updateOnlineFriendCoutner(); updateOnlineFriendCounter();
} }
if (ref?.displayName) { if (ref?.displayName) {
ctx.name = ref.displayName; ctx.name = ref.displayName;
@@ -843,7 +843,7 @@ export const useFriendStore = defineStore('Friend', () => {
reconnectWebSocket(); reconnectWebSocket();
} }
function updateOnlineFriendCoutner() { function updateOnlineFriendCounter() {
const onlineFriendCounts = const onlineFriendCounts =
vipFriends.value.length + onlineFriends.value.length; vipFriends.value.length + onlineFriends.value.length;
if (onlineFriendCounts !== onlineFriendCount.value) { if (onlineFriendCounts !== onlineFriendCount.value) {
@@ -1625,14 +1625,14 @@ export const useFriendStore = defineStore('Friend', () => {
initFriendsList, initFriendsList,
updateLocalFavoriteFriends, updateLocalFavoriteFriends,
updateSidebarFriendsList, updateSidebarFavorites,
updateFriend, updateFriend,
deleteFriend, deleteFriend,
refreshFriendsStatus, refreshFriendsStatus,
addFriend, addFriend,
refreshFriends, refreshFriends,
refreshFriendsList, refreshFriendsList,
updateOnlineFriendCoutner, updateOnlineFriendCounter,
getAllUserStats, getAllUserStats,
initFriendLog, initFriendLog,
migrateFriendLog, migrateFriendLog,
+3 -2
View File
@@ -63,12 +63,12 @@ export const useUiStore = defineStore('Ui', () => {
updateTrayIconNotify(); updateTrayIconNotify();
} }
function updateTrayIconNotify() { function updateTrayIconNotify(force = false) {
const newState = const newState =
notifiedMenus.value.includes('notification') || notifiedMenus.value.includes('notification') ||
notifiedMenus.value.includes('friendLog'); notifiedMenus.value.includes('friendLog');
if (trayIconNotify.value !== newState) { if (trayIconNotify.value !== newState || force) {
trayIconNotify.value = newState; trayIconNotify.value = newState;
if (LINUX) { if (LINUX) {
window.electron.setTrayIconNotification(trayIconNotify.value); window.electron.setTrayIconNotification(trayIconNotify.value);
@@ -77,6 +77,7 @@ export const useUiStore = defineStore('Ui', () => {
AppApi.SetTrayIconNotification(trayIconNotify.value); AppApi.SetTrayIconNotification(trayIconNotify.value);
} }
} }
updateTrayIconNotify(true);
return { return {
notifiedMenus, notifiedMenus,
+1 -1
View File
@@ -46,7 +46,7 @@ export const useVrStore = defineStore('Vr', () => {
// run these methods again to send data to the overlay // run these methods again to send data to the overlay
sharedFeedStore.updateSharedFeed(true); sharedFeedStore.updateSharedFeed(true);
friendStore.onlineFriendCount = 0; // force an update friendStore.onlineFriendCount = 0; // force an update
friendStore.updateOnlineFriendCoutner(); friendStore.updateOnlineFriendCounter();
} }
async function saveOpenVROption() { async function saveOpenVROption() {