mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
simplify
This commit is contained in:
@@ -48,7 +48,10 @@
|
||||
class="nav-menu-popover__menu-item"
|
||||
@click="handleSubmenuClick(entry.path, item.index)">
|
||||
<span class="nav-menu-popover__menu-label"
|
||||
>{{ t(entry.label) }}<span class="nav-menu-popover__menu-label-dot"></span
|
||||
>{{ t(entry.label)
|
||||
}}<span
|
||||
v-if="route.path === entry.path"
|
||||
class="nav-menu-popover__menu-label-dot"></span
|
||||
></span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -196,9 +199,9 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import {
|
||||
useAdvancedSettingsStore,
|
||||
@@ -216,6 +219,7 @@
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const navItems = [
|
||||
{
|
||||
|
||||
@@ -51,13 +51,12 @@ export function initRouter(app) {
|
||||
app.use(router);
|
||||
}
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach((to, from) => {
|
||||
if (to.path == '/') {
|
||||
next('/feed');
|
||||
return;
|
||||
return { name: 'feed' };
|
||||
}
|
||||
if (to.path === '/social' || to.path === '/social/social') {
|
||||
return false;
|
||||
}
|
||||
next();
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -188,7 +188,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
||||
D.galleryImages = [];
|
||||
D.galleryLoading = true;
|
||||
D.isFavorite =
|
||||
favoriteStore.cachedFavoritesByObjectId(avatarId) ||
|
||||
favoriteStore.getCachedFavoritesByObjectId(avatarId) ||
|
||||
(userStore.isLocalUserVrcPlusSupporter &&
|
||||
favoriteStore.localAvatarFavoritesList.includes(avatarId));
|
||||
D.isBlocked = cachedAvatarModerations.has(avatarId);
|
||||
|
||||
@@ -38,52 +38,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
|
||||
const cachedFavoriteGroups = ref({});
|
||||
|
||||
const cachedFavoriteGroupsByTypeName = computed(() => {
|
||||
const group = {};
|
||||
|
||||
for (const k in favoriteFriendGroups.value) {
|
||||
const element = favoriteFriendGroups.value[k];
|
||||
group[element.key] = element;
|
||||
}
|
||||
for (const k in favoriteWorldGroups.value) {
|
||||
const element = favoriteWorldGroups.value[k];
|
||||
group[element.key] = element;
|
||||
}
|
||||
for (const k in favoriteAvatarGroups.value) {
|
||||
const element = favoriteAvatarGroups.value[k];
|
||||
group[element.key] = element;
|
||||
}
|
||||
|
||||
return group;
|
||||
});
|
||||
|
||||
const favoriteFriends = computed(() => {
|
||||
if (appearanceSettingsStore.sortFavorites) {
|
||||
return state.favoriteFriends_;
|
||||
}
|
||||
const sorted = [...state.favoriteFriends_];
|
||||
sorted.sort(compareByName);
|
||||
return sorted;
|
||||
});
|
||||
|
||||
const favoriteWorlds = computed(() => {
|
||||
if (appearanceSettingsStore.sortFavorites) {
|
||||
return state.favoriteWorlds_;
|
||||
}
|
||||
const sorted = [...state.favoriteWorlds_];
|
||||
sorted.sort(compareByName);
|
||||
return sorted;
|
||||
});
|
||||
|
||||
const favoriteAvatars = computed(() => {
|
||||
if (appearanceSettingsStore.sortFavorites) {
|
||||
return state.favoriteAvatars_;
|
||||
}
|
||||
const sorted = [...state.favoriteAvatars_];
|
||||
sorted.sort(compareByName);
|
||||
return sorted;
|
||||
});
|
||||
|
||||
const isFavoriteGroupLoading = ref(false);
|
||||
|
||||
const favoriteFriendGroups = ref([]);
|
||||
@@ -132,13 +86,31 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
currentGroup: {}
|
||||
});
|
||||
|
||||
const cachedFavoritesByObjectId = computed(() => (objectId) => {
|
||||
for (const item of cachedFavorites.values()) {
|
||||
if (item.favoriteId === objectId) {
|
||||
return item;
|
||||
}
|
||||
const favoriteFriends = computed(() => {
|
||||
if (appearanceSettingsStore.sortFavorites) {
|
||||
return state.favoriteFriends_;
|
||||
}
|
||||
return undefined;
|
||||
const sorted = [...state.favoriteFriends_];
|
||||
sorted.sort(compareByName);
|
||||
return sorted;
|
||||
});
|
||||
|
||||
const favoriteWorlds = computed(() => {
|
||||
// if (appearanceSettingsStore.sortFavorites) {
|
||||
return state.favoriteWorlds_;
|
||||
// }
|
||||
// const sorted = [...state.favoriteWorlds_];
|
||||
// sorted.sort(compareByName);
|
||||
// return sorted;
|
||||
});
|
||||
|
||||
const favoriteAvatars = computed(() => {
|
||||
if (appearanceSettingsStore.sortFavorites) {
|
||||
return state.favoriteAvatars_;
|
||||
}
|
||||
const sorted = [...state.favoriteAvatars_];
|
||||
sorted.sort(compareByName);
|
||||
return sorted;
|
||||
});
|
||||
|
||||
const localAvatarFavoriteGroups = computed(() =>
|
||||
@@ -217,6 +189,34 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
{ flush: 'sync' }
|
||||
);
|
||||
|
||||
function getCachedFavoriteGroupsByTypeName() {
|
||||
const group = {};
|
||||
|
||||
for (const k in favoriteFriendGroups.value) {
|
||||
const element = favoriteFriendGroups.value[k];
|
||||
group[element.key] = element;
|
||||
}
|
||||
for (const k in favoriteWorldGroups.value) {
|
||||
const element = favoriteWorldGroups.value[k];
|
||||
group[element.key] = element;
|
||||
}
|
||||
for (const k in favoriteAvatarGroups.value) {
|
||||
const element = favoriteAvatarGroups.value[k];
|
||||
group[element.key] = element;
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
function getCachedFavoritesByObjectId(objectId) {
|
||||
for (const item of cachedFavorites.values()) {
|
||||
if (item.favoriteId === objectId) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function handleFavoriteAdd(args) {
|
||||
handleFavorite({
|
||||
json: args.json,
|
||||
@@ -264,7 +264,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
}
|
||||
|
||||
function handleFavoriteDelete(args) {
|
||||
const ref = cachedFavoritesByObjectId.value(args.params.objectId);
|
||||
const ref = getCachedFavoritesByObjectId(args.params.objectId);
|
||||
if (typeof ref === 'undefined') {
|
||||
return;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
*/
|
||||
async function applyFavorite(type, objectId, sortTop = false) {
|
||||
let ref;
|
||||
const favorite = cachedFavoritesByObjectId.value(objectId);
|
||||
const favorite = getCachedFavoritesByObjectId(objectId);
|
||||
let ctx = state.favoriteObjects.get(objectId);
|
||||
if (typeof favorite !== 'undefined') {
|
||||
let isTypeChanged = false;
|
||||
@@ -602,7 +602,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
// update favorites
|
||||
|
||||
for (ref of cachedFavorites.values()) {
|
||||
group = cachedFavoriteGroupsByTypeName.value[ref.$groupKey];
|
||||
group = getCachedFavoriteGroupsByTypeName()[ref.$groupKey];
|
||||
if (typeof group === 'undefined') {
|
||||
continue;
|
||||
}
|
||||
@@ -655,7 +655,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
done(ok) {
|
||||
if (ok) {
|
||||
for (const objectId of previousFavoriteIds) {
|
||||
const fav = cachedFavoritesByObjectId.value(objectId);
|
||||
const fav = getCachedFavoritesByObjectId(objectId);
|
||||
if (!newFavoriteIds.has(objectId) && fav) {
|
||||
handleFavoriteAtDelete(fav);
|
||||
}
|
||||
@@ -726,7 +726,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
friendStore.updateSidebarFavorites();
|
||||
}
|
||||
ref.$groupKey = `${ref.type}:${String(ref.tags[0])}`;
|
||||
const group = cachedFavoriteGroupsByTypeName.value[ref.$groupKey];
|
||||
const group = getCachedFavoriteGroupsByTypeName()[ref.$groupKey];
|
||||
if (typeof group !== 'undefined') {
|
||||
++group.count;
|
||||
}
|
||||
@@ -1190,7 +1190,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
avatarStore.avatarDialog.id === avatarId
|
||||
) {
|
||||
avatarStore.avatarDialog.isFavorite =
|
||||
cachedFavoritesByObjectId.value(avatarId);
|
||||
getCachedFavoritesByObjectId(avatarId);
|
||||
}
|
||||
|
||||
// update UI
|
||||
@@ -1317,7 +1317,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
worldStore.worldDialog.id === worldId
|
||||
) {
|
||||
worldStore.worldDialog.isFavorite =
|
||||
cachedFavoritesByObjectId.value(worldId);
|
||||
getCachedFavoritesByObjectId(worldId);
|
||||
}
|
||||
|
||||
// update UI
|
||||
@@ -1443,7 +1443,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
isFavoriteGroupLoading,
|
||||
favoriteFriendGroups,
|
||||
cachedFavoriteGroups,
|
||||
cachedFavoriteGroupsByTypeName,
|
||||
favoriteLimits,
|
||||
cachedFavorites,
|
||||
favoriteWorldGroups,
|
||||
@@ -1461,7 +1460,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
localAvatarFavoriteGroups,
|
||||
favoriteDialog,
|
||||
localWorldFavoritesList,
|
||||
cachedFavoritesByObjectId,
|
||||
|
||||
localWorldFavoriteGroups,
|
||||
groupedByGroupKeyFavoriteFriends,
|
||||
currentFavoriteTab,
|
||||
@@ -1502,6 +1501,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
handleFavoriteGroupClear,
|
||||
handleFavoriteGroup,
|
||||
handleFavoriteDelete,
|
||||
handleFavoriteAdd
|
||||
handleFavoriteAdd,
|
||||
getCachedFavoritesByObjectId
|
||||
};
|
||||
});
|
||||
|
||||
@@ -242,7 +242,7 @@ export const useNotificationStore = defineStore('Notification', () => {
|
||||
}
|
||||
if (
|
||||
generalSettingsStore.autoAcceptInviteRequests === 'All Favorites' &&
|
||||
!favoriteStore.favoriteFriends.some(
|
||||
!favoriteStore.state.favoriteFriends_.some(
|
||||
(x) => x.id === ref.senderUserId
|
||||
)
|
||||
) {
|
||||
|
||||
@@ -572,7 +572,9 @@ export const usePhotonStore = defineStore('Photon', () => {
|
||||
hudTimeout.forEach((item) => {
|
||||
if (
|
||||
timeoutHudOverlayFilter.value === 'VIP' &&
|
||||
favoriteStore.cachedFavoritesByObjectId(item.userId)
|
||||
favoriteStore.getCachedFavoritesByObjectId(
|
||||
item.userId
|
||||
)
|
||||
) {
|
||||
filteredHudTimeout.push(item);
|
||||
} else if (
|
||||
|
||||
@@ -861,9 +861,8 @@ export const useUserStore = defineStore('User', () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
D.isFavorite = favoriteStore.cachedFavoritesByObjectId(
|
||||
D.id
|
||||
);
|
||||
D.isFavorite =
|
||||
favoriteStore.getCachedFavoritesByObjectId(D.id);
|
||||
if (D.ref.friendRequestStatus === 'incoming') {
|
||||
D.incomingRequest = true;
|
||||
} else if (D.ref.friendRequestStatus === 'outgoing') {
|
||||
|
||||
@@ -262,7 +262,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
});
|
||||
worldStore.cachedWorlds.forEach((ref, id) => {
|
||||
if (
|
||||
!favoriteStore.cachedFavoritesByObjectId(id) &&
|
||||
!favoriteStore.getCachedFavoritesByObjectId(id) &&
|
||||
ref.authorId !== userStore.currentUser.id &&
|
||||
!favoriteStore.localWorldFavoritesList.includes(id)
|
||||
) {
|
||||
@@ -271,7 +271,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
});
|
||||
avatarStore.cachedAvatars.forEach((ref, id) => {
|
||||
if (
|
||||
!favoriteStore.cachedFavoritesByObjectId(id) &&
|
||||
!favoriteStore.getCachedFavoritesByObjectId(id) &&
|
||||
ref.authorId !== userStore.currentUser.id &&
|
||||
!favoriteStore.localAvatarFavoritesList.includes(id) &&
|
||||
!avatarStore.avatarHistory.includes(id)
|
||||
|
||||
@@ -142,7 +142,7 @@ export const useWorldStore = defineStore('World', () => {
|
||||
if (D.id === args.ref.id) {
|
||||
D.loading = false;
|
||||
D.ref = args.ref;
|
||||
D.isFavorite = favoriteStore.cachedFavoritesByObjectId(
|
||||
D.isFavorite = favoriteStore.getCachedFavoritesByObjectId(
|
||||
D.id
|
||||
);
|
||||
if (!D.isFavorite) {
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
}
|
||||
editFavoritesMode.value = false;
|
||||
}
|
||||
|
||||
function changeFavoriteGroupName(ctx) {
|
||||
ElMessageBox.prompt(
|
||||
t('prompt.change_favorite_group_name.description'),
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
style="margin-left: 5px"
|
||||
@click.stop="selectAvatarWithConfirmation(favorite.id)"></el-button>
|
||||
</el-tooltip>
|
||||
<template v-if="cachedFavoritesByObjectId(favorite.id)">
|
||||
<template v-if="getCachedFavoritesByObjectId(favorite.id)">
|
||||
<el-tooltip placement="right" content="Favorite" :teleported="false">
|
||||
<el-button
|
||||
type="default"
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const { showFavoriteDialog, cachedFavoritesByObjectId } = useFavoriteStore();
|
||||
const { showFavoriteDialog, getCachedFavoritesByObjectId } = useFavoriteStore();
|
||||
const { selectAvatarWithConfirmation } = useAvatarStore();
|
||||
const { currentUser } = storeToRefs(useUserStore());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user