mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-22 00:03:51 +02:00
refactor untils
This commit is contained in:
@@ -600,14 +600,18 @@
|
||||
import { avatarRequest } from '../../../api';
|
||||
import { database } from '../../../services/database';
|
||||
import { formatJsonVars } from '../../../shared/utils/base/ui';
|
||||
import { handleImageUploadInput } from '../../../shared/utils/imageUpload';
|
||||
import { handleImageUploadInput } from '../../../coordinators/imageUploadCoordinator';
|
||||
import { runDeleteVRChatCacheFlow as deleteVRChatCache } from '../../../coordinators/gameCoordinator';
|
||||
import { showAvatarDialog, applyAvatar, selectAvatarWithoutConfirmation } from '../../../coordinators/avatarCoordinator';
|
||||
import {
|
||||
showAvatarDialog,
|
||||
applyAvatar,
|
||||
selectAvatarWithoutConfirmation
|
||||
} from '../../../coordinators/avatarCoordinator';
|
||||
import { useAvatarDialogCommands } from './useAvatarDialogCommands';
|
||||
|
||||
import DialogJsonTab from '../DialogJsonTab.vue';
|
||||
import ImageCropDialog from '../ImageCropDialog.vue';
|
||||
import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
|
||||
const SetAvatarStylesDialog = defineAsyncComponent(() => import('./SetAvatarStylesDialog.vue'));
|
||||
const SetAvatarTagsDialog = defineAsyncComponent(() => import('./SetAvatarTagsDialog.vue'));
|
||||
@@ -617,8 +621,7 @@ import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
const avatarStore = useAvatarStore();
|
||||
const { cachedAvatarModerations, cachedAvatars } = avatarStore;
|
||||
const { avatarDialog } = storeToRefs(avatarStore);
|
||||
const { getAvatarGallery, applyAvatarModeration } =
|
||||
avatarStore;
|
||||
const { getAvatarGallery, applyAvatarModeration } = avatarStore;
|
||||
const { showFavoriteDialog } = useFavoriteStore();
|
||||
const { isGameRunning } = storeToRefs(useGameStore());
|
||||
const { showFullscreenImageDialog } = useGalleryStore();
|
||||
|
||||
@@ -30,11 +30,14 @@ vi.mock('../../../../shared/utils', () => ({
|
||||
vi.mock('../../../../shared/utils/imageUpload', () => ({
|
||||
handleImageUploadInput: vi.fn(),
|
||||
readFileAsBase64: vi.fn(),
|
||||
resizeImageToFitLimits: vi.fn(),
|
||||
uploadImageLegacy: vi.fn(),
|
||||
withUploadTimeout: vi.fn()
|
||||
}));
|
||||
|
||||
vi.mock('../../../../coordinators/imageUploadCoordinator', () => ({
|
||||
resizeImageToFitLimits: vi.fn(),
|
||||
uploadImageLegacy: vi.fn()
|
||||
}));
|
||||
|
||||
const { copyToClipboard, openExternalLink } =
|
||||
await import('../../../../shared/utils');
|
||||
const { favoriteRequest, avatarRequest, avatarModerationRequest } =
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
import {
|
||||
avatarModerationRequest,
|
||||
avatarRequest,
|
||||
@@ -11,18 +12,32 @@ import {
|
||||
} from '../../../shared/utils';
|
||||
import {
|
||||
handleImageUploadInput,
|
||||
readFileAsBase64,
|
||||
resizeImageToFitLimits,
|
||||
uploadImageLegacy,
|
||||
uploadImageLegacy
|
||||
} from '../../../coordinators/imageUploadCoordinator';
|
||||
import {
|
||||
readFileAsBase64,
|
||||
withUploadTimeout
|
||||
} from '../../../shared/utils/imageUpload';
|
||||
|
||||
/**
|
||||
* Composable for AvatarDialog command dispatch.
|
||||
* Uses a command map pattern instead of nested switch-case chains.
|
||||
*
|
||||
* @param {import('vue').Ref} avatarDialog - reactive ref to the avatar dialog state
|
||||
* @param {object} deps - external dependencies
|
||||
* @param deps.t
|
||||
* @param deps.toast
|
||||
* @param deps.modalStore
|
||||
* @param deps.userDialog
|
||||
* @param deps.currentUser
|
||||
* @param deps.cachedAvatars
|
||||
* @param deps.cachedAvatarModerations
|
||||
* @param deps.showAvatarDialog
|
||||
* @param deps.showFavoriteDialog
|
||||
* @param deps.applyAvatarModeration
|
||||
* @param deps.applyAvatar
|
||||
* @param deps.sortUserDialogAvatars
|
||||
* @param deps.uiStore
|
||||
* @returns {object} command composable API
|
||||
*/
|
||||
export function useAvatarDialogCommands(
|
||||
@@ -205,6 +220,9 @@ export function useAvatarDialogCommands(
|
||||
// String commands: delegate to component callback
|
||||
// Confirmed commands: { confirm: () => ({title, description, ...}), handler: fn }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function buildCommandMap() {
|
||||
const D = () => avatarDialog.value;
|
||||
|
||||
|
||||
@@ -352,16 +352,16 @@
|
||||
getFaviconUrl,
|
||||
hasGroupPermission,
|
||||
openExternalLink,
|
||||
refreshInstancePlayerCount,
|
||||
userImage,
|
||||
userStatusClass
|
||||
} from '../../../shared/utils';
|
||||
import { refreshInstancePlayerCount } from '../../../coordinators/instanceCoordinator';
|
||||
import { useGalleryStore, useGroupStore, useInstanceStore, useLocationStore, useUserStore } from '../../../stores';
|
||||
import { useGroupCalendarEvents } from './useGroupCalendarEvents';
|
||||
|
||||
import GroupCalendarEventCard from '../../../views/Tools/components/GroupCalendarEventCard.vue';
|
||||
import InstanceActionBar from '../../InstanceActionBar.vue';
|
||||
import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
|
||||
const props = defineProps({
|
||||
showGroupPostEditDialog: {
|
||||
@@ -376,7 +376,6 @@ import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
|
||||
const { groupDialog } = storeToRefs(useGroupStore());
|
||||
const { lastLocation } = storeToRefs(useLocationStore());
|
||||
const { showFullscreenImageDialog } = useGalleryStore();
|
||||
|
||||
@@ -54,7 +54,8 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { miscRequest, userRequest } from '../../../api';
|
||||
import { replaceBioSymbols, saveUserMemo } from '../../../shared/utils';
|
||||
import { replaceBioSymbols } from '../../../shared/utils';
|
||||
import { saveUserMemo } from '../../../coordinators/memoCoordinator';
|
||||
import { useAppearanceSettingsStore, useUserStore } from '../../../stores';
|
||||
|
||||
const { userDialog } = storeToRefs(useUserStore());
|
||||
|
||||
@@ -483,13 +483,13 @@
|
||||
isFriendOnline,
|
||||
isRealInstance,
|
||||
openExternalLink,
|
||||
refreshInstancePlayerCount,
|
||||
timeToText,
|
||||
userImage,
|
||||
userOnlineFor,
|
||||
userOnlineForTimestamp,
|
||||
userStatusClass
|
||||
} from '../../../shared/utils';
|
||||
import { refreshInstancePlayerCount } from '../../../coordinators/instanceCoordinator';
|
||||
import {
|
||||
useAdvancedSettingsStore,
|
||||
useAppearanceSettingsStore,
|
||||
@@ -505,7 +505,7 @@
|
||||
import { queryRequest, userRequest } from '../../../api';
|
||||
|
||||
import InstanceActionBar from '../../InstanceActionBar.vue';
|
||||
import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
import { showUserDialog } from '../../../coordinators/userCoordinator';
|
||||
|
||||
const EditNoteAndMemoDialog = defineAsyncComponent(() => import('./EditNoteAndMemoDialog.vue'));
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { refreshInstancePlayerCount } from '../../../shared/utils';
|
||||
import { refreshInstancePlayerCount } from '../../../coordinators/instanceCoordinator';
|
||||
import { useUserDisplay } from '../../../composables/useUserDisplay';
|
||||
import {
|
||||
useAppearanceSettingsStore,
|
||||
@@ -125,7 +125,7 @@
|
||||
const { userImage, userStatusClass } = useUserDisplay();
|
||||
|
||||
const { isAgeGatedInstancesVisible } = storeToRefs(useAppearanceSettingsStore());
|
||||
|
||||
|
||||
const { currentUser } = storeToRefs(useUserStore());
|
||||
const { worldDialog } = storeToRefs(useWorldStore());
|
||||
const { lastLocation } = storeToRefs(useLocationStore());
|
||||
|
||||
@@ -28,11 +28,14 @@ vi.mock('../../../../shared/utils', () => ({
|
||||
vi.mock('../../../../shared/utils/imageUpload', () => ({
|
||||
handleImageUploadInput: vi.fn(),
|
||||
readFileAsBase64: vi.fn(),
|
||||
resizeImageToFitLimits: vi.fn(),
|
||||
uploadImageLegacy: vi.fn(),
|
||||
withUploadTimeout: vi.fn((p) => p)
|
||||
}));
|
||||
|
||||
vi.mock('../../../../coordinators/imageUploadCoordinator', () => ({
|
||||
resizeImageToFitLimits: vi.fn(),
|
||||
uploadImageLegacy: vi.fn()
|
||||
}));
|
||||
|
||||
const { favoriteRequest, miscRequest, userRequest, worldRequest } =
|
||||
await import('../../../../api');
|
||||
const { openExternalLink } = await import('../../../../shared/utils');
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import { nextTick, ref } from 'vue';
|
||||
|
||||
import {
|
||||
handleImageUploadInput,
|
||||
readFileAsBase64,
|
||||
resizeImageToFitLimits,
|
||||
uploadImageLegacy,
|
||||
withUploadTimeout
|
||||
} from '../../../shared/utils/imageUpload';
|
||||
import {
|
||||
favoriteRequest,
|
||||
miscRequest,
|
||||
userRequest,
|
||||
worldRequest
|
||||
} from '../../../api';
|
||||
import {
|
||||
handleImageUploadInput,
|
||||
resizeImageToFitLimits,
|
||||
uploadImageLegacy
|
||||
} from '../../../coordinators/imageUploadCoordinator';
|
||||
import { openExternalLink, replaceVrcPackageUrl } from '../../../shared/utils';
|
||||
import {
|
||||
readFileAsBase64,
|
||||
withUploadTimeout
|
||||
} from '../../../shared/utils/imageUpload';
|
||||
|
||||
/**
|
||||
* Composable for WorldDialog commands, prompt functions, and image upload.
|
||||
@@ -370,6 +372,9 @@ export function useWorldDialogCommands(
|
||||
// String commands: delegate to component callback
|
||||
// Confirmed commands: { confirm: () => ({title, description, ...}), handler: fn }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function buildCommandMap() {
|
||||
const D = () => worldDialog.value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user