Updates and fixes

This commit is contained in:
Natsumi
2024-05-23 21:11:46 +12:00
parent d9bb77d395
commit 55ebcb1ad7
5 changed files with 27 additions and 38 deletions

View File

@@ -1690,6 +1690,10 @@ speechSynthesis.getVoices();
};
API.applyPresenceGroups = function (ref) {
if (!this.currentUserGroupsInit) {
// wait for init before diffing
return;
}
var groups = ref.presence?.groups;
if (!groups) {
console.error('API.applyPresenceGroups: invalid groups', ref);
@@ -1700,14 +1704,6 @@ speechSynthesis.getVoices();
return;
}
if (groups.length !== this.currentUserGroups.size) {
console.log(
`applyPresenceGroups: size old: ${this.currentUserGroups.size} new: ${groups.length}`,
this.currentUserGroups,
groups
);
}
// update group list
for (var groupId of groups) {
if (!this.currentUserGroups.has(groupId)) {
@@ -4427,6 +4423,7 @@ speechSynthesis.getVoices();
}
this.refreshFavoriteItems();
this.refreshFavoriteGroups();
$app.updateLocalFavoriteFriends();
this.isFavoriteLoading = false;
}
});
@@ -24768,10 +24765,10 @@ speechSynthesis.getVoices();
$app.methods.getCurrentUserGroups = async function () {
var args = await API.getGroups({ userId: API.currentUser.id });
API.currentUserGroups.clear();
args.json.forEach((group) => {
for (var group of args.json) {
var ref = API.applyGroup(group);
API.currentUserGroups.set(group.id, ref);
});
}
await API.getGroupPermissions({ userId: API.currentUser.id });
this.saveCurrentUserGroups();
};
@@ -26451,12 +26448,14 @@ speechSynthesis.getVoices();
};
$app.methods.isRealInstance = function (instanceId) {
if (!instanceId) {
return false;
}
switch (instanceId) {
case 'offline':
case 'private':
case 'traveling':
case instanceId.startsWith('local'):
case '':
return false;
}
return true;
@@ -27898,7 +27897,7 @@ speechSynthesis.getVoices();
this.localFavoriteFriends.clear();
for (var ref of API.cachedFavorites.values()) {
if (
ref.$isDeleted === false &&
!ref.$isDeleted &&
ref.type === 'friend' &&
(this.localFavoriteFriendsGroups.length === 0 ||
this.localFavoriteFriendsGroups.includes(ref.$groupKey))
@@ -29790,7 +29789,6 @@ speechSynthesis.getVoices();
API.currentUserGroups.set(group.id, ref);
}
var fetchedRoles = false;
if (groups) {
for (var i = 0; i < groups.length; i++) {
var groupId = groups[i];
@@ -29809,7 +29807,6 @@ speechSynthesis.getVoices();
});
var ref = API.applyGroup(args.json);
API.currentUserGroups.set(groupId, ref);
fetchedRoles = true;
console.log(`Fetched group ${ref.name}`);
} catch (err) {
console.error(err);
@@ -29818,9 +29815,6 @@ speechSynthesis.getVoices();
}
this.currentUserGroupsInit = true;
if (fetchedRoles) {
this.saveCurrentUserGroups();
}
};
API.applyGroupMember = function (json) {
@@ -30189,23 +30183,18 @@ speechSynthesis.getVoices();
// ignore this event if we were the one to trigger it
return;
}
// if (this.groupDialog.visible && this.groupDialog.id === groupId) {
// this.showGroupDialog(groupId);
// }
if (!API.currentUserGroups.has(groupId)) {
API.currentUserGroups.set(groupId, {
id: groupId,
name: '',
iconUrl: ''
});
if (this.friendLogInitStatus) {
API.getGroup({ groupId, includeRoles: true }).then((args) => {
var ref = API.applyGroup(args.json);
API.currentUserGroups.set(groupId, ref);
this.saveCurrentUserGroups();
return args;
});
}
API.getGroup({ groupId, includeRoles: true }).then((args) => {
var ref = API.applyGroup(args.json);
API.currentUserGroups.set(groupId, ref);
this.saveCurrentUserGroups();
return args;
});
}
};