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