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