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