mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
fix: load mutual friends button and mutual opt-out status in friend list
This commit is contained in:
+8
-11
@@ -322,6 +322,14 @@ export const useChartsStore = defineStore('Charts', () => {
|
||||
mutualGraphStatus.friendSignature = friendCount.value;
|
||||
mutualGraphStatus.needsRefetch = false;
|
||||
|
||||
// Write meta first so saveMutualGraphSnapshot's DELETE
|
||||
// uses up-to-date opted_out flags to decide what to preserve.
|
||||
// If this fails, we must NOT proceed with snapshot save because
|
||||
// the DELETE would use stale meta and corrupt data.
|
||||
if (metaEntries.size > 0) {
|
||||
await database.bulkUpsertMutualGraphMeta(metaEntries);
|
||||
}
|
||||
|
||||
try {
|
||||
const entries = new Map();
|
||||
mutualMap.forEach((value, friendId) => {
|
||||
@@ -348,17 +356,6 @@ export const useChartsStore = defineStore('Charts', () => {
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
if (metaEntries.size > 0) {
|
||||
await database.bulkUpsertMutualGraphMeta(metaEntries);
|
||||
}
|
||||
} catch (metaErr) {
|
||||
console.error(
|
||||
'[MutualNetworkGraph] Failed to write meta',
|
||||
metaErr
|
||||
);
|
||||
}
|
||||
|
||||
markMutualGraphLoaded({ notify: true });
|
||||
return mutualMap;
|
||||
} catch (err) {
|
||||
|
||||
@@ -61,6 +61,7 @@ export const useFriendStore = defineStore('Friend', () => {
|
||||
let pendingSortedFriendsRebuild = false;
|
||||
let allUserStatsRequestId = 0;
|
||||
let allUserMutualCountRequestId = 0;
|
||||
let allUserMutualOptedOutRequestId = 0;
|
||||
|
||||
const derivedDebugCounters = reactive({
|
||||
allFavoriteFriendIds: 0,
|
||||
@@ -904,6 +905,11 @@ export const useFriendStore = defineStore('Friend', () => {
|
||||
return;
|
||||
}
|
||||
runInSortedFriendsBatch(() => {
|
||||
for (const ctx of friends.values()) {
|
||||
if (ctx?.ref) {
|
||||
ctx.ref.$mutualCount = 0;
|
||||
}
|
||||
}
|
||||
for (const [userId, mutualCount] of mutualCountMap.entries()) {
|
||||
const ref = friends.get(userId);
|
||||
if (ref?.ref) {
|
||||
@@ -914,6 +920,33 @@ export const useFriendStore = defineStore('Friend', () => {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function getAllUserMutualOptedOut() {
|
||||
if (!friends.size) {
|
||||
return;
|
||||
}
|
||||
const requestId = ++allUserMutualOptedOutRequestId;
|
||||
const metaMap = await database.getMutualGraphMeta();
|
||||
if (requestId !== allUserMutualOptedOutRequestId) {
|
||||
return;
|
||||
}
|
||||
runInSortedFriendsBatch(() => {
|
||||
for (const ctx of friends.values()) {
|
||||
if (ctx?.ref) {
|
||||
ctx.ref.$mutualOptedOut = false;
|
||||
}
|
||||
}
|
||||
for (const [userId, meta] of metaMap.entries()) {
|
||||
const ref = friends.get(userId);
|
||||
if (ref?.ref) {
|
||||
ref.ref.$mutualOptedOut = Boolean(meta.optedOut);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} id
|
||||
@@ -1398,6 +1431,7 @@ export const useFriendStore = defineStore('Friend', () => {
|
||||
updateOnlineFriendCounter,
|
||||
getAllUserStats,
|
||||
getAllUserMutualCount,
|
||||
getAllUserMutualOptedOut,
|
||||
initFriendLog,
|
||||
migrateFriendLog,
|
||||
getFriendLog,
|
||||
|
||||
Reference in New Issue
Block a user