Sort favorites option

This commit is contained in:
Natsumi
2022-03-18 11:10:31 +13:00
parent 7a795843e8
commit fea294e1cc
2 changed files with 38 additions and 6 deletions

View File

@@ -10217,8 +10217,11 @@ speechSynthesis.getVoices();
$app.data.favoriteObjects = new Map();
$app.data.favoriteFriends_ = [];
$app.data.favoriteFriendsSorted = [];
$app.data.favoriteWorlds_ = [];
$app.data.favoriteWorldsSorted = [];
$app.data.favoriteAvatars_ = [];
$app.data.favoriteAvatarsSorted = [];
$app.data.sortFavoriteFriends = false;
$app.data.sortFavoriteWorlds = false;
$app.data.sortFavoriteAvatars = false;
@@ -10226,8 +10229,11 @@ speechSynthesis.getVoices();
API.$on('LOGIN', function () {
$app.favoriteObjects.clear();
$app.favoriteFriends_ = [];
$app.favoriteFriendsSorted = [];
$app.favoriteWorlds_ = [];
$app.favoriteWorldsSorted = [];
$app.favoriteAvatars_ = [];
$app.favoriteAvatarsSorted = [];
$app.sortFavoriteFriends = false;
$app.sortFavoriteWorlds = false;
$app.sortFavoriteAvatars = false;
@@ -10298,10 +10304,13 @@ speechSynthesis.getVoices();
isTypeChanged = true;
if (type === 'friend') {
removeFromArray(this.favoriteFriends_, ctx);
removeFromArray(this.favoriteFriendsSorted, ctx);
} else if (type === 'world') {
removeFromArray(this.favoriteWorlds_, ctx);
removeFromArray(this.favoriteWorldsSorted, ctx);
} else if (type === 'avatar') {
removeFromArray(this.favoriteAvatars_, ctx);
removeFromArray(this.favoriteAvatarsSorted, ctx);
}
}
if (type === 'friend') {
@@ -10342,12 +10351,15 @@ speechSynthesis.getVoices();
if (isTypeChanged) {
if (type === 'friend') {
this.favoriteFriends_.push(ctx);
this.favoriteFriendsSorted.push(ctx);
this.sortFavoriteFriends = true;
} else if (type === 'world') {
this.favoriteWorlds_.push(ctx);
this.favoriteWorldsSorted.push(ctx);
this.sortFavoriteWorlds = true;
} else if (type === 'avatar') {
this.favoriteAvatars_.push(ctx);
this.favoriteAvatarsSorted.push(ctx);
this.sortFavoriteAvatars = true;
}
}
@@ -10355,10 +10367,13 @@ speechSynthesis.getVoices();
this.favoriteObjects.delete(objectId);
if (type === 'friend') {
removeFromArray(this.favoriteFriends_, ctx);
removeFromArray(this.favoriteFriendsSorted, ctx);
} else if (type === 'world') {
removeFromArray(this.favoriteWorlds_, ctx);
removeFromArray(this.favoriteWorldsSorted, ctx);
} else if (type === 'avatar') {
removeFromArray(this.favoriteAvatars_, ctx);
removeFromArray(this.favoriteAvatarsSorted, ctx);
}
}
};
@@ -10426,25 +10441,37 @@ speechSynthesis.getVoices();
$app.computed.favoriteFriends = function () {
if (this.sortFavoriteFriends) {
this.sortFavoriteFriends = false;
this.favoriteFriends_.sort(compareByName);
this.favoriteFriendsSorted.sort(compareByName);
}
if (this.sortFavorites) {
return this.favoriteFriends_;
} else {
return this.favoriteFriendsSorted;
}
return this.favoriteFriends_;
};
$app.computed.favoriteWorlds = function () {
if (this.sortFavoriteWorlds) {
this.sortFavoriteWorlds = false;
this.favoriteWorlds_.sort(compareByName);
this.favoriteWorldsSorted.sort(compareByName);
}
if (this.sortFavorites) {
return this.favoriteWorlds_;
} else {
return this.favoriteWorldsSorted;
}
return this.favoriteWorlds_;
};
$app.computed.favoriteAvatars = function () {
if (this.sortFavoriteAvatars) {
this.sortFavoriteAvatars = false;
this.favoriteAvatars_.sort(compareByName);
this.favoriteAvatarsSorted.sort(compareByName);
}
if (this.sortFavorites) {
return this.favoriteAvatars_;
} else {
return this.favoriteAvatarsSorted;
}
return this.favoriteAvatars_;
};
// App: friendLog
@@ -11244,6 +11271,7 @@ speechSynthesis.getVoices();
$app.data.avatarRemoteDatabaseProvider = configRepository.getString(
'VRCX_avatarRemoteDatabaseProvider'
);
$app.data.sortFavorites = configRepository.getBool('VRCX_sortFavorites');
$app.methods.saveOpenVROption = function () {
configRepository.setBool('openVR', this.openVR);
configRepository.setBool('openVRAlways', this.openVRAlways);
@@ -11309,6 +11337,7 @@ speechSynthesis.getVoices();
'VRCX_avatarRemoteDatabase',
this.avatarRemoteDatabase
);
configRepository.setBool('VRCX_sortFavorites', this.sortFavorites);
this.updateSharedFeed(true);
this.updateVRConfigVars();
AppApi.ExecuteVrOverlayFunction('notyClear', '');

View File

@@ -943,6 +943,9 @@ html
div.options-container-item
span.name Disable Tooltips
el-switch(v-model="hideTooltips" @change="saveOpenVROption")
div.options-container-item
span.name Sort Favorites By
el-switch(v-model="sortFavorites" inactive-text="name" active-text="date" @change="saveOpenVROption")
div.options-container-item
el-button(size="small" icon="el-icon-notebook-1" @click="promptMaxTableSizeDialog") Table Max Size
div.options-container-item