mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-23 00:33:50 +02:00
refactor utils
This commit is contained in:
39
src/composables/useInviteChecks.js
Normal file
39
src/composables/useInviteChecks.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
useFriendStore,
|
||||
useInstanceStore,
|
||||
useLocationStore,
|
||||
useUserStore
|
||||
} from '../stores';
|
||||
import {
|
||||
checkCanInvite as checkCanInvitePure,
|
||||
checkCanInviteSelf as checkCanInviteSelfPure
|
||||
} from '../shared/utils/invite';
|
||||
|
||||
/**
|
||||
* Composable that provides store-aware invite check functions.
|
||||
* Delegates to the pure utility functions after resolving store data.
|
||||
*/
|
||||
export function useInviteChecks() {
|
||||
const userStore = useUserStore();
|
||||
const locationStore = useLocationStore();
|
||||
const instanceStore = useInstanceStore();
|
||||
const friendStore = useFriendStore();
|
||||
|
||||
function checkCanInvite(location) {
|
||||
return checkCanInvitePure(location, {
|
||||
currentUserId: userStore.currentUser.id,
|
||||
lastLocationStr: locationStore.lastLocation.location,
|
||||
cachedInstances: instanceStore.cachedInstances
|
||||
});
|
||||
}
|
||||
|
||||
function checkCanInviteSelf(location) {
|
||||
return checkCanInviteSelfPure(location, {
|
||||
currentUserId: userStore.currentUser.id,
|
||||
cachedInstances: instanceStore.cachedInstances,
|
||||
friends: friendStore.friends
|
||||
});
|
||||
}
|
||||
|
||||
return { checkCanInvite, checkCanInviteSelf };
|
||||
}
|
||||
43
src/composables/useUserDisplay.js
Normal file
43
src/composables/useUserDisplay.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import { useAppearanceSettingsStore, useUserStore } from '../stores';
|
||||
import {
|
||||
userImage as userImagePure,
|
||||
userImageFull as userImageFullPure,
|
||||
userStatusClass as userStatusClassPure
|
||||
} from '../shared/utils/user';
|
||||
|
||||
/**
|
||||
* Composable that provides store-aware user display functions.
|
||||
* Delegates to the pure utility functions after resolving store data.
|
||||
*/
|
||||
export function useUserDisplay() {
|
||||
const userStore = useUserStore();
|
||||
const appearanceStore = useAppearanceSettingsStore();
|
||||
|
||||
function userStatusClass(user, pendingOffline = false) {
|
||||
return userStatusClassPure(user, pendingOffline, userStore.currentUser);
|
||||
}
|
||||
|
||||
function userImage(
|
||||
user,
|
||||
isIcon = false,
|
||||
resolution = '128',
|
||||
isUserDialogIcon = false
|
||||
) {
|
||||
return userImagePure(
|
||||
user,
|
||||
isIcon,
|
||||
resolution,
|
||||
isUserDialogIcon,
|
||||
appearanceStore.displayVRCPlusIconsAsAvatar
|
||||
);
|
||||
}
|
||||
|
||||
function userImageFull(user) {
|
||||
return userImageFullPure(
|
||||
user,
|
||||
appearanceStore.displayVRCPlusIconsAsAvatar
|
||||
);
|
||||
}
|
||||
|
||||
return { userStatusClass, userImage, userImageFull };
|
||||
}
|
||||
Reference in New Issue
Block a user