Skip to content

Commit

Permalink
Refresh local avatars/worlds button
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Nov 5, 2024
1 parent 26fda35 commit 253b537
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
48 changes: 48 additions & 0 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19799,6 +19799,29 @@ speechSynthesis.getVoices();
$app.getLocalWorldFavorites();
});

$app.methods.refreshLocalWorldFavorites = async function () {
if (this.refreshingLocalFavorites) {
return;
}
this.refreshingLocalFavorites = true;
for (var worldId of this.localWorldFavoritesList) {
if (!this.refreshingLocalFavorites) {
break;
}
try {
await API.getWorld({
worldId
});
} catch (err) {
console.error(err);
}
await new Promise((resolve) => {
workerTimers.setTimeout(resolve, 1000);
});
}
this.refreshingLocalFavorites = false;
};

$app.data.worldFavoriteSearch = '';
$app.data.worldFavoriteSearchResults = [];

Expand Down Expand Up @@ -20187,6 +20210,31 @@ speechSynthesis.getVoices();
});
};

$app.data.refreshingLocalFavorites = false;

$app.methods.refreshLocalAvatarFavorites = async function () {
if (this.refreshingLocalFavorites) {
return;
}
this.refreshingLocalFavorites = true;
for (var avatarId of this.localAvatarFavoritesList) {
if (!this.refreshingLocalFavorites) {
break;
}
try {
await API.getAvatar({
avatarId
});
} catch (err) {
console.error(err);
}
await new Promise((resolve) => {
workerTimers.setTimeout(resolve, 1000);
});
}
this.refreshingLocalFavorites = false;
};

$app.data.avatarFavoriteSearch = '';
$app.data.avatarFavoriteSearchResults = [];

Expand Down
8 changes: 6 additions & 2 deletions html/src/localization/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@
"search": "Search",
"vrchat_favorites": "VRChat Favorites",
"local_favorites": "Local Favorites",
"new_group": "New Group"
"new_group": "New Group",
"refresh": "Refresh",
"cancel_refresh": "Cancel Refresh"
},
"avatars": {
"header": "Avatars",
"search": "Search",
"vrchat_favorites": "VRChat Favorites",
"local_favorites": "Local Favorites (Requires VRC+)",
"new_group": "New Group"
"new_group": "New Group",
"refresh": "Refresh",
"cancel_refresh": "Cancel Refresh"
},
"bulk_unfavorite_mode": "Bulk Unfavorite Mode",
"bulk_unfavorite_selection": "Bulk Unfavorite Selection",
Expand Down
20 changes: 15 additions & 5 deletions html/src/mixins/tabs/favorites.pug
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mixin favoritesTab()
el-tab-pane(:label="$t('view.favorite.friends.header')")
el-collapse(v-if="$refs.menu && $refs.menu.activeIndex === 'favorite' && $refs.favoriteTabRef && $refs.favoriteTabRef.currentName === '0'" style="border:0")
el-button(size="small" @click="showFriendExportDialog") {{ $t('view.favorite.export') }}
el-button(size="small" @click="showFriendImportDialog") {{ $t('view.favorite.import') }}
el-button(size="small" @click="showFriendImportDialog" style="margin-left:5px") {{ $t('view.favorite.import') }}
div(style="display:inline-block;float:right;font-size:13px;margin-right:10px")
span.name(style="margin-right:5px") {{ $t('view.favorite.sort_by') }}
el-switch(v-model="sortFavorites" :inactive-text="$t('view.settings.appearance.appearance.sort_favorite_by_name')" :active-text="$t('view.settings.appearance.appearance.sort_favorite_by_date')" @change="saveSortFavoritesOption")
Expand Down Expand Up @@ -54,7 +54,7 @@ mixin favoritesTab()
el-tab-pane(:label="$t('view.favorite.worlds.header')")
el-collapse(v-if="$refs.menu && $refs.menu.activeIndex === 'favorite' && $refs.favoriteTabRef && $refs.favoriteTabRef.currentName === '1'" style="border:0")
el-button(size="small" @click="showWorldExportDialog") {{ $t('view.favorite.export') }}
el-button(size="small" @click="showWorldImportDialog") {{ $t('view.favorite.import') }}
el-button(size="small" @click="showWorldImportDialog" style="margin-left:5px") {{ $t('view.favorite.import') }}
div(style="display:inline-block;float:right;font-size:13px;margin-right:10px")
span.name(style="margin-right:5px") {{ $t('view.favorite.sort_by') }}
el-switch(v-model="sortFavorites" :inactive-text="$t('view.settings.appearance.appearance.sort_favorite_by_name')" :active-text="$t('view.settings.appearance.appearance.sort_favorite_by_date')" @change="saveSortFavoritesOption")
Expand Down Expand Up @@ -124,7 +124,12 @@ mixin favoritesTab()
i.el-icon-warning(style="color:#f56c6c;margin-left:5px")
el-button(type="text" icon="el-icon-close" size="mini" @click.stop="deleteFavorite(favorite.id)" style="margin-left:5px")
span(style="display:block;margin-top:20px") {{ $t('view.favorite.worlds.local_favorites') }}
el-button(size="small" @click="promptNewLocalWorldFavoriteGroup" style="display:block;margin-top:10px") {{ $t('view.favorite.worlds.new_group') }}
br
el-button(size="small" @click="promptNewLocalWorldFavoriteGroup") {{ $t('view.favorite.worlds.new_group') }}
el-button(v-if="!refreshingLocalFavorites" size="small" @click="refreshLocalWorldFavorites" style="margin-left:5px") {{ $t('view.favorite.worlds.refresh') }}
el-button(v-else size="small" @click="refreshingLocalFavorites = false" style="margin-left:5px")
i.el-icon-loading(style="margin-right:5px")
span {{ $t('view.favorite.worlds.cancel_refresh') }}
el-collapse-item(v-for="group in localWorldFavoriteGroups" v-if="localWorldFavorites[group]" :key="group")
template(slot="title")
span(v-text="group" style="font-weight:bold;font-size:14px;margin-left:10px")
Expand Down Expand Up @@ -153,7 +158,7 @@ mixin favoritesTab()
el-tab-pane(:label="$t('view.favorite.avatars.header')")
el-collapse(v-if="$refs.menu && $refs.menu.activeIndex === 'favorite' && $refs.favoriteTabRef && $refs.favoriteTabRef.currentName === '2'" style="border:0")
el-button(size="small" @click="showAvatarExportDialog") {{ $t('view.favorite.export') }}
el-button(size="small" @click="showAvatarImportDialog") {{ $t('view.favorite.import') }}
el-button(size="small" @click="showAvatarImportDialog" style="margin-left:5px") {{ $t('view.favorite.import') }}
div(style="display:inline-block;float:right;font-size:13px;margin-right:10px")
span.name(style="margin-right:5px") {{ $t('view.favorite.sort_by') }}
el-switch(v-model="sortFavorites" :inactive-text="$t('view.settings.appearance.appearance.sort_favorite_by_name')" :active-text="$t('view.settings.appearance.appearance.sort_favorite_by_date')" @change="saveSortFavoritesOption")
Expand Down Expand Up @@ -237,7 +242,12 @@ mixin favoritesTab()
el-tooltip(placement="right" content="Favorite" :disabled="hideTooltips")
el-button(@click.stop="showFavoriteDialog('avatar', favorite.id)" type="default" icon="el-icon-star-off" size="mini" circle style="margin-left:5px")
span(style="display:block;margin-top:20px") {{ $t('view.favorite.avatars.local_favorites') }}
el-button(size="small" :disabled="!isLocalUserVrcplusSupporter()" @click="promptNewLocalAvatarFavoriteGroup" style="display:block;margin-top:10px") {{ $t('view.favorite.avatars.new_group') }}
br
el-button(size="small" :disabled="!isLocalUserVrcplusSupporter()" @click="promptNewLocalAvatarFavoriteGroup") {{ $t('view.favorite.avatars.new_group') }}
el-button(v-if="!refreshingLocalFavorites" size="small" @click="refreshLocalAvatarFavorites" style=";margin-left:5px") {{ $t('view.favorite.avatars.refresh') }}
el-button(v-else size="small" @click="refreshingLocalFavorites = false" style="margin-left:5px")
i.el-icon-loading(style="margin-right:5px")
span {{ $t('view.favorite.avatars.cancel_refresh') }}
el-collapse-item(v-for="group in localAvatarFavoriteGroups" v-if="localAvatarFavorites[group]" :key="group")
template(slot="title")
span(v-text="group" style="font-weight:bold;font-size:14px;margin-left:10px")
Expand Down

0 comments on commit 253b537

Please sign in to comment.