mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-14 12:23:52 +02:00
fix: fix the bug of favorite friends (#1101)
* feat: favorite friends divide by different favorite group * fix: make the update of dividing by favorite groups compatible with previous features * fix: fix the bug of favorite friends * fix: fix the bug of favorite friends
This commit is contained in:
98
src/app.js
98
src/app.js
@@ -2848,6 +2848,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
API.$on('LOGIN', function () {
|
||||
$app.localFavoriteFriends.clear();
|
||||
$app.currentUserGroupsInit = false;
|
||||
$app.localFavoriteFriendsDivideByGroup = new Map();
|
||||
this.cachedFavorites.clear();
|
||||
this.cachedFavoritesByObjectId.clear();
|
||||
this.cachedFavoriteGroups.clear();
|
||||
@@ -2925,7 +2926,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
// 애초에 $isDeleted인데 여기로 올 수 가 있나..?
|
||||
this.cachedFavoritesByObjectId.delete(args.params.objectId);
|
||||
$app.localFavoriteFriends.delete(args.params.objectId);
|
||||
$app.localFavoriteFriendsDivideByGroup.forEach((key, group) => {
|
||||
$app.localFavoriteFriendsDivideByGroup.forEach((group, key) => {
|
||||
for (let i = group.length - 1; i >= 0; i--) {
|
||||
if (group[i].id === args.params.objectId) {
|
||||
group.splice(i, 1);
|
||||
@@ -2989,7 +2990,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
this.cachedFavoritesByObjectId.delete(ref.favoriteId);
|
||||
$app.localFavoriteFriends.delete(ref.favoriteId);
|
||||
$app.localFavoriteFriendsDivideByGroup.forEach((key, group) => {
|
||||
$app.localFavoriteFriendsDivideByGroup.forEach((group, key) => {
|
||||
for (let i = group.length - 1; i >= 0; i--) {
|
||||
if (group[i].id === ref.favoriteId) {
|
||||
group.splice(i, 1);
|
||||
@@ -3066,6 +3067,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
$app.localFavoriteFriendsGroups.includes(ref.groupKey))
|
||||
) {
|
||||
$app.localFavoriteFriends.add(ref.favoriteId);
|
||||
$app.localFavoriteFriendsDivideByGroup.get(ref.$groupKey) &&
|
||||
$app.localFavoriteFriendsDivideByGroup
|
||||
.get(ref.$groupKey)
|
||||
.push(ref.favoriteId);
|
||||
$app.updateSidebarFriendsList();
|
||||
}
|
||||
} else {
|
||||
@@ -3078,9 +3083,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
ref.favoriteId
|
||||
]);
|
||||
} else {
|
||||
$app.localFavoriteFriendsDivideByGroup
|
||||
.get(ref.$groupKey)
|
||||
.push(ref.favoriteId);
|
||||
$app.localFavoriteFriendsDivideByGroup.get(ref.$groupKey) &&
|
||||
$app.localFavoriteFriendsDivideByGroup
|
||||
.get(ref.$groupKey)
|
||||
.push(ref.favoriteId);
|
||||
}
|
||||
|
||||
if (ref.$isDeleted === false && ref.$groupRef === null) {
|
||||
@@ -3095,6 +3101,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
|
||||
API.expireFavorites = function () {
|
||||
$app.localFavoriteFriends.clear();
|
||||
$app.localFavoriteFriendsDivideByGroup = new Map();
|
||||
this.cachedFavorites.clear();
|
||||
this.cachedFavoritesByObjectId.clear();
|
||||
$app.favoriteObjects.clear();
|
||||
@@ -4503,10 +4510,12 @@ console.log(`isLinux: ${LINUX}`);
|
||||
Array.from(
|
||||
this.localFavoriteFriendsDivideByGroup.entries()
|
||||
).find(([_, ids]) => ids.includes(ctx.id))?.[0] || '';
|
||||
if (!this.vipFriendsDivideByGroup_.has(key)) {
|
||||
this.vipFriendsDivideByGroup_.set(key, [ctx]);
|
||||
} else {
|
||||
this.vipFriendsDivideByGroup_.get(key).push(ctx);
|
||||
if (key) {
|
||||
if (!this.vipFriendsDivideByGroup_.has(key)) {
|
||||
this.vipFriendsDivideByGroup_.set(key, [ctx]);
|
||||
} else {
|
||||
this.vipFriendsDivideByGroup_.get(key).push(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
this.sortVIPFriends = true;
|
||||
@@ -4532,7 +4541,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
if (ctx.state === 'online') {
|
||||
if (ctx.isVIP) {
|
||||
$app.removeFromArray(this.vipFriends_, ctx);
|
||||
this.vipFriendsDivideByGroup_.forEach((key, group) => {
|
||||
this.vipFriendsDivideByGroup_.forEach((group, key) => {
|
||||
for (let i = group.length - 1; i >= 0; i--) {
|
||||
if (group[i].id === ctx.id) {
|
||||
group.splice(i, 1);
|
||||
@@ -4542,6 +4551,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.vipFriendsDivideByGroup_.delete(key);
|
||||
}
|
||||
});
|
||||
const mapClone = new Map(
|
||||
Array.from(this.vipFriendsDivideByGroup_)
|
||||
);
|
||||
this.vipFriendsDivideByGroup_ = mapClone;
|
||||
} else {
|
||||
$app.removeFromArray(this.onlineFriends_, ctx);
|
||||
}
|
||||
@@ -4611,16 +4624,20 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.localFavoriteFriendsDivideByGroup.entries()
|
||||
).find(([_, ids]) => ids.includes(ctx.id))?.[0] ||
|
||||
'';
|
||||
if (!this.vipFriendsDivideByGroup_.has(key)) {
|
||||
this.vipFriendsDivideByGroup_.set(key, [ctx]);
|
||||
} else {
|
||||
this.vipFriendsDivideByGroup_.get(key).push(ctx);
|
||||
if (key) {
|
||||
if (!this.vipFriendsDivideByGroup_.has(key)) {
|
||||
this.vipFriendsDivideByGroup_.set(key, [ctx]);
|
||||
} else {
|
||||
this.vipFriendsDivideByGroup_
|
||||
.get(key)
|
||||
.push(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
this.sortVIPFriends = true;
|
||||
} else {
|
||||
$app.removeFromArray(this.vipFriends_, ctx);
|
||||
this.vipFriendsDivideByGroup_.forEach((key, group) => {
|
||||
this.vipFriendsDivideByGroup_.forEach((group, key) => {
|
||||
for (let i = group.length - 1; i >= 0; i--) {
|
||||
if (group[i].id === ctx.id) {
|
||||
group.splice(i, 1);
|
||||
@@ -4630,6 +4647,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.vipFriendsDivideByGroup_.delete(key);
|
||||
}
|
||||
});
|
||||
const mapClone = new Map(
|
||||
Array.from(this.vipFriendsDivideByGroup_)
|
||||
);
|
||||
this.vipFriendsDivideByGroup_ = mapClone;
|
||||
this.onlineFriends_.push(ctx);
|
||||
this.sortOnlineFriends = true;
|
||||
}
|
||||
@@ -4823,7 +4844,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
if (ctx.state === 'online') {
|
||||
if (ctx.isVIP) {
|
||||
$app.removeFromArray(this.vipFriends_, ctx);
|
||||
this.vipFriendsDivideByGroup_.forEach((key, group) => {
|
||||
this.vipFriendsDivideByGroup_.forEach((group, key) => {
|
||||
for (let i = group.length - 1; i >= 0; i--) {
|
||||
if (group[i].id === ctx.id) {
|
||||
group.splice(i, 1);
|
||||
@@ -4833,6 +4854,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.vipFriendsDivideByGroup_.delete(key);
|
||||
}
|
||||
});
|
||||
const mapClone = new Map(
|
||||
Array.from(this.vipFriendsDivideByGroup_)
|
||||
);
|
||||
this.vipFriendsDivideByGroup_ = mapClone;
|
||||
} else {
|
||||
$app.removeFromArray(this.onlineFriends_, ctx);
|
||||
}
|
||||
@@ -4848,10 +4873,12 @@ console.log(`isLinux: ${LINUX}`);
|
||||
Array.from(
|
||||
this.localFavoriteFriendsDivideByGroup.entries()
|
||||
).find(([_, ids]) => ids.includes(ctx.id))?.[0] || '';
|
||||
if (!this.vipFriendsDivideByGroup_.has(key)) {
|
||||
this.vipFriendsDivideByGroup_.set(key, [ctx]);
|
||||
} else {
|
||||
this.vipFriendsDivideByGroup_.get(key).push(ctx);
|
||||
if (key) {
|
||||
if (!this.vipFriendsDivideByGroup_.has(key)) {
|
||||
this.vipFriendsDivideByGroup_.set(key, [ctx]);
|
||||
} else {
|
||||
this.vipFriendsDivideByGroup_.get(key).push(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
this.sortVIPFriends = true;
|
||||
@@ -5235,7 +5262,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
)?.displayName
|
||||
});
|
||||
}
|
||||
// 对this.vipFriendsDivideByGroup_的每一项的value值数组进行filter操作,只留下id存在于this.vipFriendsByGroupStatus中的所有项的id中的项
|
||||
|
||||
if (this.isSidebarGroupByInstance) {
|
||||
const vipFriendsByGroupStatusIds = new Set(
|
||||
this.vipFriendsByGroupStatus.map((friend) => friend.id)
|
||||
@@ -22088,16 +22115,20 @@ console.log(`isLinux: ${LINUX}`);
|
||||
'[]'
|
||||
)
|
||||
);
|
||||
|
||||
$app.data.localFavoriteFriendsDivideByGroup = JSON.parse(
|
||||
await configRepository.getString(
|
||||
'VRCX_localFavoriteFriendsDivideByGroup',
|
||||
'[]'
|
||||
)
|
||||
);
|
||||
$app.methods.updateLocalFavoriteFriends = function () {
|
||||
this.localFavoriteFriends.clear();
|
||||
this.localFavoriteFriendsDivideByGroup.clear();
|
||||
this.localFavoriteFriendsDivideByGroup = new Map();
|
||||
for (var ref of API.cachedFavorites.values()) {
|
||||
if (
|
||||
!ref.$isDeleted &&
|
||||
ref.type === 'friend' &&
|
||||
(this.localFavoriteFriendsGroups.length === 0 ||
|
||||
this.localFavoriteFriendsGroups.includes(ref.$groupKey))
|
||||
this.localFavoriteFriendsGroups.includes(ref.$groupKey)
|
||||
) {
|
||||
this.localFavoriteFriends.add(ref.favoriteId);
|
||||
if (
|
||||
@@ -22107,9 +22138,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
ref.favoriteId
|
||||
]);
|
||||
} else {
|
||||
this.localFavoriteFriendsDivideByGroup
|
||||
.get(ref.$groupKey)
|
||||
.push(ref.favoriteId);
|
||||
this.localFavoriteFriendsDivideByGroup.get(ref.$groupKey) &&
|
||||
this.localFavoriteFriendsDivideByGroup
|
||||
.get(ref.$groupKey)
|
||||
.push(ref.favoriteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22119,6 +22151,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
'VRCX_localFavoriteFriendsGroups',
|
||||
JSON.stringify(this.localFavoriteFriendsGroups)
|
||||
);
|
||||
configRepository.setString(
|
||||
'VRCX_localFavoriteFriendsDivideByGroup',
|
||||
JSON.stringify(this.localFavoriteFriendsDivideByGroup)
|
||||
);
|
||||
};
|
||||
|
||||
$app.methods.updateSidebarFriendsList = function () {
|
||||
@@ -22147,7 +22183,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.sortVIPFriends = true;
|
||||
} else {
|
||||
$app.removeFromArray(this.vipFriends_, ctx);
|
||||
this.vipFriendsDivideByGroup_.forEach((key, group) => {
|
||||
this.vipFriendsDivideByGroup_.forEach((group, key) => {
|
||||
for (let i = group.length - 1; i >= 0; i--) {
|
||||
if (group[i].id === ctx.id) {
|
||||
group.splice(i, 1);
|
||||
@@ -22157,6 +22193,10 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.vipFriendsDivideByGroup_.delete(key);
|
||||
}
|
||||
});
|
||||
const mapClone = new Map(
|
||||
Array.from(this.vipFriendsDivideByGroup_)
|
||||
);
|
||||
this.vipFriendsDivideByGroup_ = mapClone;
|
||||
this.onlineFriends_.push(ctx);
|
||||
this.sortOnlineFriends = true;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ mixin friendsListSidebar
|
||||
:traveling='lastLocationDestination'
|
||||
:link='false')
|
||||
location.extra(
|
||||
v-else-if='isRealInstance(API.currentUser.$locationTag) || isRealInstance(API.currentUser.$travelingToLocation)'
|
||||
v-else-if='isRealInstance(API.currentUser.$locationTag) || isRealInstance(API.currentUser.$travelingToLocation)'
|
||||
:location='API.currentUser.$locationTag'
|
||||
:traveling='API.currentUser.$travelingToLocation'
|
||||
:link='false')
|
||||
@@ -74,7 +74,7 @@ mixin friendsListSidebar
|
||||
i.el-icon-arrow-right(:class='{ rotate: isVIPFriends }')
|
||||
span(style='margin-left: 5px') {{ $t('side_panel.favorite') }} ― {{ vipFriendsByGroupStatus.length }}
|
||||
div(v-show='isVIPFriends')
|
||||
template(v-if='isSidebarDivideByFriendGroup')
|
||||
template(v-if='isSidebarDivideByFriendGroup && localFavoriteFriendsGroups.length')
|
||||
div(v-for='(group, idx) in vipFriendsDivideByGroup' :key='idx')
|
||||
div(style='margin-bottom: 3px')
|
||||
span.extra {{ group.displayName }}
|
||||
|
||||
Reference in New Issue
Block a user