mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-11 02:43:50 +02:00
user types
This commit is contained in:
@@ -23,17 +23,16 @@ const userReq = {
|
||||
}
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
params,
|
||||
ref: userStore.applyUser(json)
|
||||
};
|
||||
args.ref = userStore.applyUser(json);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch user from cache if they're in it. Otherwise, calls API.
|
||||
* @param {{ userId: string }} params identifier of registered user
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
* @type {import('../types/user').getUser}
|
||||
*/
|
||||
getCachedUser(params) {
|
||||
const userStore = useUserStore();
|
||||
@@ -150,8 +149,7 @@ const userReq = {
|
||||
|
||||
/**
|
||||
* Updates current user's status.
|
||||
* @param params {SaveCurrentUserParameters} new status to be set
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
* @type {import('../types/user').getCurrentUser}
|
||||
*/
|
||||
saveCurrentUser(params) {
|
||||
const userStore = useUserStore();
|
||||
@@ -161,9 +159,9 @@ const userReq = {
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
params,
|
||||
ref: userStore.applyCurrentUser(json)
|
||||
};
|
||||
userStore.applyCurrentUser(json);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -422,7 +422,7 @@ export const useInstanceStore = defineStore('Instance', () => {
|
||||
/**
|
||||
*
|
||||
* @param {string} worldId
|
||||
* @param {string} options
|
||||
* @param {any} options
|
||||
* @returns {Promise<{json: *, params}|null>}
|
||||
*/
|
||||
async function createNewInstance(worldId = '', options) {
|
||||
@@ -1000,8 +1000,8 @@ export const useInstanceStore = defineStore('Instance', () => {
|
||||
/**
|
||||
*
|
||||
* @param {string} instanceId
|
||||
* @param {string} position
|
||||
* @param {string} queueSize
|
||||
* @param {number} position
|
||||
* @param {number} queueSize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function instanceQueueUpdate(instanceId, position, queueSize) {
|
||||
|
||||
@@ -118,6 +118,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
presence: {
|
||||
avatarThumbnail: '',
|
||||
currentAvatarTags: '',
|
||||
debugflag: '',
|
||||
displayName: '',
|
||||
groups: [],
|
||||
id: '',
|
||||
@@ -132,6 +133,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
world: ''
|
||||
},
|
||||
profilePicOverride: '',
|
||||
profilePicOverrideThumbnail: '',
|
||||
pronouns: '',
|
||||
queuedInstance: '',
|
||||
state: '',
|
||||
@@ -153,10 +155,10 @@ export const useUserStore = defineStore('User', () => {
|
||||
viveId: '',
|
||||
// VRCX
|
||||
$online_for: Date.now(),
|
||||
$offline_for: '',
|
||||
$offline_for: null,
|
||||
$location_at: Date.now(),
|
||||
$travelingToTime: Date.now(),
|
||||
$previousAvatarSwapTime: '',
|
||||
$previousAvatarSwapTime: null,
|
||||
$homeLocation: {},
|
||||
$isVRCPlus: false,
|
||||
$isModerator: false,
|
||||
@@ -434,8 +436,8 @@ export const useUserStore = defineStore('User', () => {
|
||||
const robotUrl = `${AppGlobal.endpointDomain}/file/file_0e8c4e32-7444-44ea-ade4-313c010d4bae/1/file`;
|
||||
/**
|
||||
*
|
||||
* @param json
|
||||
* @returns {any}
|
||||
* @param {import('../types/user').getUserResponse} json
|
||||
* @returns {import('../types/user').vrcxUser}
|
||||
*/
|
||||
function applyUser(json) {
|
||||
let hasPropChanged = false;
|
||||
@@ -500,7 +502,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
$location_at: Date.now(),
|
||||
$online_for: Date.now(),
|
||||
$travelingToTime: Date.now(),
|
||||
$offline_for: '',
|
||||
$offline_for: null,
|
||||
$active_for: Date.now(),
|
||||
$isVRCPlus: false,
|
||||
$isModerator: false,
|
||||
@@ -550,7 +552,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
}
|
||||
state.cachedUsers.set(ref.id, ref);
|
||||
} else {
|
||||
json.$lastFetch = Date.now();
|
||||
json.$lastFetch = Date.now(); // todo: make this not suck
|
||||
if (json.state !== 'online') {
|
||||
// offline event before GPS to offline location
|
||||
friendStore.updateFriend(ref.id, json.state);
|
||||
@@ -1021,7 +1023,6 @@ export const useUserStore = defineStore('User', () => {
|
||||
})
|
||||
.then((args) => {
|
||||
Vue.set(L, 'user', args.ref);
|
||||
return args;
|
||||
});
|
||||
} else {
|
||||
L.user = ref;
|
||||
@@ -1234,7 +1235,6 @@ export const useUserStore = defineStore('User', () => {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} ref
|
||||
* @param {object} props
|
||||
* @returns {Promise<void>}
|
||||
@@ -1739,6 +1739,10 @@ export const useUserStore = defineStore('User', () => {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('../types/user').getCurrentUserResponse} json
|
||||
* @returns {import('../types/user').getCurrentUserResponse}
|
||||
*/
|
||||
function applyCurrentUser(json) {
|
||||
authStore.attemptingAutoLogin = false;
|
||||
let ref = state.currentUser;
|
||||
@@ -1801,6 +1805,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
presence: {
|
||||
avatarThumbnail: '',
|
||||
currentAvatarTags: '',
|
||||
debugflag: '',
|
||||
displayName: '',
|
||||
groups: [],
|
||||
id: '',
|
||||
@@ -1816,6 +1821,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
...json.presence
|
||||
},
|
||||
profilePicOverride: '',
|
||||
profilePicOverrideThumbnail: '',
|
||||
pronouns: '',
|
||||
queuedInstance: '',
|
||||
state: '',
|
||||
@@ -1837,10 +1843,10 @@ export const useUserStore = defineStore('User', () => {
|
||||
viveId: '',
|
||||
// VRCX
|
||||
$online_for: Date.now(),
|
||||
$offline_for: '',
|
||||
$offline_for: null,
|
||||
$location_at: Date.now(),
|
||||
$travelingToTime: Date.now(),
|
||||
$previousAvatarSwapTime: '',
|
||||
$previousAvatarSwapTime: null,
|
||||
$homeLocation: {},
|
||||
$isVRCPlus: false,
|
||||
$isModerator: false,
|
||||
@@ -1913,7 +1919,9 @@ export const useUserStore = defineStore('User', () => {
|
||||
travelingToInstance = json.presence.travelingToInstance;
|
||||
travelingToWorld = json.presence.travelingToWorld;
|
||||
}
|
||||
applyUser({
|
||||
const userRef = applyUser({
|
||||
ageVerificationStatus: json.ageVerificationStatus,
|
||||
ageVerified: json.ageVerified,
|
||||
allowAvatarCopying: json.allowAvatarCopying,
|
||||
badges: json.badges,
|
||||
bio: json.bio,
|
||||
@@ -1934,10 +1942,10 @@ export const useUserStore = defineStore('User', () => {
|
||||
last_mobile: json.last_mobile,
|
||||
last_platform: json.last_platform,
|
||||
// location - missing from currentUser
|
||||
// platform - missing from currentUser
|
||||
// note - missing from currentUser
|
||||
platform: json.presence.platform,
|
||||
profilePicOverride: json.profilePicOverride,
|
||||
// profilePicOverrideThumbnail - missing from currentUser
|
||||
profilePicOverrideThumbnail: json.profilePicOverrideThumbnail,
|
||||
pronouns: json.pronouns,
|
||||
state: json.state,
|
||||
status: json.status,
|
||||
@@ -1948,7 +1956,7 @@ export const useUserStore = defineStore('User', () => {
|
||||
// travelingToWorld - missing from currentUser
|
||||
userIcon: json.userIcon,
|
||||
// worldId - missing from currentUser
|
||||
fallbackAvatar: json.fallbackAvatar,
|
||||
// fallbackAvatar - gone from user
|
||||
|
||||
// Location from gameLog/presence
|
||||
location,
|
||||
@@ -1956,14 +1964,20 @@ export const useUserStore = defineStore('User', () => {
|
||||
worldId,
|
||||
travelingToLocation,
|
||||
travelingToInstance,
|
||||
travelingToWorld,
|
||||
travelingToWorld
|
||||
|
||||
// set VRCX online/offline timers
|
||||
$online_for: state.currentUser.$online_for,
|
||||
$offline_for: state.currentUser.$offline_for,
|
||||
$location_at: state.currentUser.$location_at,
|
||||
$travelingToTime: state.currentUser.$travelingToTime
|
||||
// $online_for: state.currentUser.$online_for,
|
||||
// $offline_for: state.currentUser.$offline_for,
|
||||
// $location_at: state.currentUser.$location_at,
|
||||
// $travelingToTime: state.currentUser.$travelingToTime
|
||||
});
|
||||
// set VRCX online/offline timers
|
||||
userRef.$online_for = state.currentUser.$online_for;
|
||||
userRef.$offline_for = state.currentUser.$offline_for;
|
||||
userRef.$location_at = state.currentUser.$location_at;
|
||||
userRef.$travelingToTime = state.currentUser.$travelingToTime;
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
120
src/types/user.d.ts
vendored
120
src/types/user.d.ts
vendored
@@ -1,8 +1,37 @@
|
||||
export type getUser = (params: { userId: string }) => Promise<{
|
||||
cache?: boolean;
|
||||
json: getUserResponse;
|
||||
ref: vrcxUser;
|
||||
params: { userId: string };
|
||||
}>;
|
||||
|
||||
export interface vrcxUser extends getUserResponse {
|
||||
$location: {};
|
||||
$location_at: number;
|
||||
$online_for: number;
|
||||
$travelingToTime: number;
|
||||
$offline_for: number;
|
||||
$active_for: number;
|
||||
$isVRCPlus: boolean;
|
||||
$isModerator: boolean;
|
||||
$isTroll: boolean;
|
||||
$isProbableTroll: boolean;
|
||||
$trustLevel: string;
|
||||
$trustClass: string;
|
||||
$userColour: string;
|
||||
$trustSortNum: number;
|
||||
$languages: string[];
|
||||
$joinCount: number;
|
||||
$timeSpent: number;
|
||||
$lastSeen: string;
|
||||
$nickName: string;
|
||||
$previousLocation: string;
|
||||
$customTag: string;
|
||||
$customTagColour: string;
|
||||
$friendNumber: number;
|
||||
$lastFetch: number;
|
||||
}
|
||||
|
||||
interface getUserResponse {
|
||||
ageVerificationStatus: string;
|
||||
ageVerified: boolean;
|
||||
@@ -23,17 +52,17 @@ interface getUserResponse {
|
||||
developerType: string;
|
||||
displayName: string;
|
||||
friendKey: string;
|
||||
friendRequestStatus: string;
|
||||
friendRequestStatus?: string;
|
||||
id: string;
|
||||
instanceId: string;
|
||||
instanceId?: string;
|
||||
isFriend: boolean;
|
||||
last_activity: string;
|
||||
last_login: string;
|
||||
last_mobile: string | null;
|
||||
last_platform: string;
|
||||
location: string;
|
||||
note: string;
|
||||
platform: string;
|
||||
location?: string;
|
||||
note?: string;
|
||||
platform?: string;
|
||||
profilePicOverride: string;
|
||||
profilePicOverrideThumbnail: string;
|
||||
pronouns: string;
|
||||
@@ -41,9 +70,82 @@ interface getUserResponse {
|
||||
status: string;
|
||||
statusDescription: string;
|
||||
tags: string[];
|
||||
travelingToInstance: string;
|
||||
travelingToLocation: string;
|
||||
travelingToWorld: string;
|
||||
travelingToInstance?: string;
|
||||
travelingToLocation?: string;
|
||||
travelingToWorld?: string;
|
||||
userIcon: string;
|
||||
worldId: string;
|
||||
worldId?: string;
|
||||
}
|
||||
|
||||
export type getCurrentUser = (any) => Promise<{
|
||||
json: getCurrentUserResponse;
|
||||
ref: vrcxCurrentUser;
|
||||
params: getCurrentUserResponse;
|
||||
}>;
|
||||
|
||||
export interface vrcxCurrentUser extends getCurrentUserResponse {
|
||||
$online_for?: number;
|
||||
$offline_for?: number | null;
|
||||
$location_at?: number;
|
||||
$travelingToTime?: number;
|
||||
$previousAvatarSwapTime?: number | null;
|
||||
$homeLocation?: {};
|
||||
$isVRCPlus?: boolean;
|
||||
$isModerator?: boolean;
|
||||
$isTroll?: boolean;
|
||||
$isProbableTroll?: boolean;
|
||||
$trustLevel?: string;
|
||||
$trustClass?: string;
|
||||
$userColour?: string;
|
||||
$trustSortNum?: number;
|
||||
$languages?: string[];
|
||||
$locationTag?: string;
|
||||
$travelingToLocation?: string;
|
||||
}
|
||||
|
||||
interface getCurrentUserResponse extends getUserResponse {
|
||||
acceptedPrivacyVersion: number;
|
||||
acceptedTOSVersion: number;
|
||||
accountDeletionDate: string | null;
|
||||
accountDeletionLog: string | null;
|
||||
activeFriends: string[];
|
||||
currentAvatar: string;
|
||||
emailVerified: boolean;
|
||||
fallbackAvatar: string;
|
||||
friendGroupNames: string[];
|
||||
friends: string[];
|
||||
googleId: string;
|
||||
hasBirthday: boolean;
|
||||
hasEmail: boolean;
|
||||
hasLoggedInFromClient: boolean;
|
||||
hasPendingEmail: boolean;
|
||||
hideContentFilterSettings: boolean;
|
||||
homeLocation: string;
|
||||
isAdult: boolean;
|
||||
isBoopingEnabled: boolean;
|
||||
obfuscatedEmail: string;
|
||||
obfuscatedPendingEmail: string;
|
||||
oculusId: string;
|
||||
offlineFriends: string[];
|
||||
onlineFriends: string[];
|
||||
pastDisplayNames: { displayName: string; dateChanged: string }[];
|
||||
picoId: string;
|
||||
presence?: {
|
||||
avatarThumbnail: string;
|
||||
currentAvatarTags: string;
|
||||
debugflag: string;
|
||||
displayName: string;
|
||||
groups: string[];
|
||||
id: string;
|
||||
instance: string;
|
||||
instanceType: string;
|
||||
platform: string;
|
||||
profilePicOverride: string;
|
||||
status: string;
|
||||
travelingToInstance: string;
|
||||
travelingToWorld: string;
|
||||
userIcon: string;
|
||||
world: string;
|
||||
};
|
||||
queuedInstance: string | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user