mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
refactor store
This commit is contained in:
1259
src/coordinators/favoriteCoordinator.js
Normal file
1259
src/coordinators/favoriteCoordinator.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,8 @@ import { AppDebug } from '../service/appConfig';
|
||||
import { database } from '../service/database';
|
||||
import { useFeedStore } from '../stores/feed';
|
||||
import { useFriendStore } from '../stores/friend';
|
||||
import { useNotificationStore } from '../stores/notification';
|
||||
import { useSharedFeedStore } from '../stores/sharedFeed';
|
||||
import { useUserStore } from '../stores/user';
|
||||
import { userRequest } from '../api';
|
||||
import { watchState } from '../service/watchState';
|
||||
@@ -25,6 +27,8 @@ export async function runUpdateFriendDelayedCheckFlow(
|
||||
) {
|
||||
const friendStore = useFriendStore();
|
||||
const feedStore = useFeedStore();
|
||||
const notificationStore = useNotificationStore();
|
||||
const sharedFeedStore = useSharedFeedStore();
|
||||
const { friends, localFavoriteFriends } = friendStore;
|
||||
|
||||
let feed;
|
||||
@@ -72,7 +76,9 @@ export async function runUpdateFriendDelayedCheckFlow(
|
||||
groupName,
|
||||
time
|
||||
};
|
||||
feedStore.addFeed(feed);
|
||||
notificationStore.queueFeedNoty(feed);
|
||||
sharedFeedStore.addEntry(feed);
|
||||
feedStore.addFeedEntry(feed);
|
||||
database.addOnlineOfflineToDatabase(feed);
|
||||
} else if (
|
||||
newState === 'online' &&
|
||||
@@ -96,7 +102,9 @@ export async function runUpdateFriendDelayedCheckFlow(
|
||||
groupName,
|
||||
time: ''
|
||||
};
|
||||
feedStore.addFeed(feed);
|
||||
notificationStore.queueFeedNoty(feed);
|
||||
sharedFeedStore.addEntry(feed);
|
||||
feedStore.addFeedEntry(feed);
|
||||
database.addOnlineOfflineToDatabase(feed);
|
||||
}
|
||||
if (newState === 'active') {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { database } from '../service/database';
|
||||
import { friendRequest } from '../api';
|
||||
import { handleFavoriteDelete } from './favoriteCoordinator';
|
||||
import { useAppearanceSettingsStore } from '../stores/settings/appearance';
|
||||
import { useFavoriteStore } from '../stores/favorite';
|
||||
import { useFriendStore } from '../stores/friend';
|
||||
@@ -56,7 +57,7 @@ export function runDeleteFriendshipFlow(
|
||||
sharedFeedStore.addEntry(friendLogHistory);
|
||||
friendLog.delete(id);
|
||||
database.deleteFriendLogCurrent(id);
|
||||
favoriteStore.handleFavoriteDelete(id);
|
||||
handleFavoriteDelete(id);
|
||||
if (!appearanceSettingsStore.hideUnfriends) {
|
||||
uiStore.notifyMenu('friend-log');
|
||||
}
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import { toast } from 'vue-sonner';
|
||||
|
||||
import {
|
||||
deleteVRChatCache as _deleteVRChatCache,
|
||||
isRealInstance
|
||||
} from '../shared/utils';
|
||||
import { database } from '../service/database';
|
||||
import { useAdvancedSettingsStore } from '../stores/settings/advanced';
|
||||
import { useAvatarStore } from '../stores/avatar';
|
||||
import { useGameLogStore } from '../stores/gameLog';
|
||||
import { useGameStore } from '../stores/game';
|
||||
import { useInstanceStore } from '../stores/instance';
|
||||
import { useLaunchStore } from '../stores/launch';
|
||||
import { useLocationStore } from '../stores/location';
|
||||
import { runLastLocationResetFlow } from './locationCoordinator';
|
||||
import { useModalStore } from '../stores/modal';
|
||||
import { useNotificationStore } from '../stores/notification';
|
||||
import { useUpdateLoopStore } from '../stores/updateLoop';
|
||||
import { useUserStore } from '../stores/user';
|
||||
import { useVrStore } from '../stores/vr';
|
||||
import { useWorldStore } from '../stores/world';
|
||||
|
||||
import configRepository from '../service/config';
|
||||
|
||||
@@ -31,15 +44,208 @@ export async function runGameRunningChangedFlow(isGameRunning) {
|
||||
await configRepository.setBool('isGameNoVR', gameStore.isGameNoVR);
|
||||
userStore.markCurrentUserGameStopped();
|
||||
instanceStore.removeAllQueuedInstances();
|
||||
gameStore.autoVRChatCacheManagement();
|
||||
gameStore.checkIfGameCrashed();
|
||||
runAutoVRChatCacheManagementFlow();
|
||||
runCheckIfGameCrashedFlow();
|
||||
updateLoopStore.setIpcTimeout(0);
|
||||
avatarStore.addAvatarWearTime(userStore.currentUser.currentAvatar);
|
||||
}
|
||||
|
||||
locationStore.lastLocationReset();
|
||||
runLastLocationResetFlow();
|
||||
gameLogStore.clearNowPlaying();
|
||||
vrStore.updateVRLastLocation();
|
||||
workerTimers.setTimeout(() => gameStore.checkVRChatDebugLogging(), 60000);
|
||||
workerTimers.setTimeout(() => runCheckVRChatDebugLoggingFlow(), 60000);
|
||||
updateLoopStore.setNextDiscordUpdate(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Orchestrates the game running state update from IPC.
|
||||
* @param {boolean} isGameRunningArg Game running flag from IPC.
|
||||
* @param {boolean} isSteamVRRunningArg SteamVR running flag from IPC.
|
||||
*/
|
||||
export async function runUpdateIsGameRunningFlow(
|
||||
isGameRunningArg,
|
||||
isSteamVRRunningArg
|
||||
) {
|
||||
const gameStore = useGameStore();
|
||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||
const vrStore = useVrStore();
|
||||
|
||||
if (advancedSettingsStore.gameLogDisabled) {
|
||||
return;
|
||||
}
|
||||
if (isGameRunningArg !== gameStore.isGameRunning) {
|
||||
gameStore.setIsGameRunning(isGameRunningArg);
|
||||
await runGameRunningChangedFlow(isGameRunningArg);
|
||||
console.log(new Date(), 'isGameRunning', isGameRunningArg);
|
||||
}
|
||||
|
||||
if (isSteamVRRunningArg !== gameStore.isSteamVRRunning) {
|
||||
gameStore.setIsSteamVRRunning(isSteamVRRunningArg);
|
||||
console.log('isSteamVRRunning:', isSteamVRRunningArg);
|
||||
}
|
||||
vrStore.updateOpenVR();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs auto cache management if enabled.
|
||||
*/
|
||||
function runAutoVRChatCacheManagementFlow() {
|
||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||
|
||||
if (advancedSettingsStore.autoSweepVRChatCache) {
|
||||
runSweepVRChatCacheFlow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sweeps VRChat cache and refreshes cache size display if config dialog visible.
|
||||
*/
|
||||
export async function runSweepVRChatCacheFlow() {
|
||||
const gameStore = useGameStore();
|
||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||
|
||||
try {
|
||||
const output = await AssetBundleManager.SweepCache();
|
||||
console.log('SweepCache', output);
|
||||
} catch (e) {
|
||||
console.error('SweepCache failed', e);
|
||||
}
|
||||
if (advancedSettingsStore.isVRChatConfigDialogVisible) {
|
||||
gameStore.getVRChatCacheSize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes VRChat cache for a given ref and refreshes related stores.
|
||||
* @param {object} ref Avatar or world reference payload.
|
||||
*/
|
||||
export async function runDeleteVRChatCacheFlow(ref) {
|
||||
const gameStore = useGameStore();
|
||||
const worldStore = useWorldStore();
|
||||
const avatarStore = useAvatarStore();
|
||||
|
||||
await _deleteVRChatCache(ref);
|
||||
gameStore.getVRChatCacheSize();
|
||||
worldStore.updateVRChatWorldCache();
|
||||
avatarStore.updateVRChatAvatarCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if VRChat crashed and attempts to relaunch.
|
||||
*/
|
||||
export function runCheckIfGameCrashedFlow() {
|
||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||
const locationStore = useLocationStore();
|
||||
const gameStore = useGameStore();
|
||||
|
||||
if (!advancedSettingsStore.relaunchVRChatAfterCrash) {
|
||||
return;
|
||||
}
|
||||
const { location } = locationStore.lastLocation;
|
||||
AppApi.VrcClosedGracefully().then((result) => {
|
||||
if (result || !isRealInstance(location)) {
|
||||
return;
|
||||
}
|
||||
// check if relaunched less than 2mins ago (prevent crash loop)
|
||||
if (
|
||||
gameStore.state.lastCrashedTime &&
|
||||
new Date().getTime() -
|
||||
gameStore.state.lastCrashedTime.getTime() <
|
||||
120_000
|
||||
) {
|
||||
console.log('VRChat was recently crashed, not relaunching');
|
||||
return;
|
||||
}
|
||||
gameStore.setLastCrashedTime(new Date());
|
||||
// wait a bit for SteamVR to potentially close before deciding to relaunch
|
||||
let restartDelay = 8000;
|
||||
if (gameStore.isGameNoVR) {
|
||||
// wait for game to close before relaunching
|
||||
restartDelay = 2000;
|
||||
}
|
||||
workerTimers.setTimeout(
|
||||
() => runRestartCrashedGameFlow(location),
|
||||
restartDelay
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts VRChat after a crash.
|
||||
* @param {string} location Last known location to relaunch.
|
||||
*/
|
||||
function runRestartCrashedGameFlow(location) {
|
||||
const gameStore = useGameStore();
|
||||
const notificationStore = useNotificationStore();
|
||||
const gameLogStore = useGameLogStore();
|
||||
const launchStore = useLaunchStore();
|
||||
|
||||
if (!gameStore.isGameNoVR && !gameStore.isSteamVRRunning) {
|
||||
console.log("SteamVR isn't running, not relaunching VRChat");
|
||||
return;
|
||||
}
|
||||
AppApi.FocusWindow();
|
||||
const message = 'VRChat crashed, attempting to rejoin last instance';
|
||||
toast(message);
|
||||
const entry = {
|
||||
created_at: new Date().toJSON(),
|
||||
type: 'Event',
|
||||
data: message
|
||||
};
|
||||
database.addGamelogEventToDatabase(entry);
|
||||
notificationStore.queueGameLogNoty(entry);
|
||||
gameLogStore.addGameLog(entry);
|
||||
launchStore.launchGame(location, '', gameStore.isGameNoVR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and re-enables VRChat debug logging if disabled.
|
||||
*/
|
||||
export async function runCheckVRChatDebugLoggingFlow() {
|
||||
const gameStore = useGameStore();
|
||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||
const modalStore = useModalStore();
|
||||
|
||||
if (advancedSettingsStore.gameLogDisabled) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const loggingEnabled = await gameStore.getVRChatRegistryKey(
|
||||
'LOGGING_ENABLED'
|
||||
);
|
||||
if (
|
||||
loggingEnabled === null ||
|
||||
typeof loggingEnabled === 'undefined'
|
||||
) {
|
||||
// key not found
|
||||
return;
|
||||
}
|
||||
if (parseInt(loggingEnabled, 10) === 1) {
|
||||
// already enabled
|
||||
return;
|
||||
}
|
||||
const result = await AppApi.SetVRChatRegistryKey(
|
||||
'LOGGING_ENABLED',
|
||||
'1',
|
||||
4
|
||||
);
|
||||
if (!result) {
|
||||
// failed to set key
|
||||
modalStore.alert({
|
||||
description:
|
||||
'VRCX has noticed VRChat debug logging is disabled. VRCX requires debug logging in order to function correctly. Please enable debug logging in VRChat quick menu settings > debug > enable debug logging, then rejoin the instance or restart VRChat.',
|
||||
title: 'Enable debug logging'
|
||||
});
|
||||
console.error('Failed to enable debug logging', result);
|
||||
return;
|
||||
}
|
||||
modalStore.alert({
|
||||
description:
|
||||
'VRCX has noticed VRChat debug logging is disabled and automatically re-enabled it. VRCX requires debug logging in order to function correctly.',
|
||||
title: 'Enabled debug logging'
|
||||
});
|
||||
console.log('Enabled debug logging');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
48
src/coordinators/inviteCoordinator.js
Normal file
48
src/coordinators/inviteCoordinator.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { toast } from 'vue-sonner';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { instanceRequest } from '../api';
|
||||
import { parseLocation } from '../shared/utils';
|
||||
import { useInstanceStore } from '../stores/instance';
|
||||
import { useInviteStore } from '../stores/invite';
|
||||
import { useLaunchStore } from '../stores/launch';
|
||||
|
||||
/**
|
||||
* Creates a new instance for the given world and either opens it in-game
|
||||
* or sends a self-invite, depending on game state.
|
||||
* @param {string} worldId
|
||||
*/
|
||||
export function runNewInstanceSelfInviteFlow(worldId) {
|
||||
const instanceStore = useInstanceStore();
|
||||
const launchStore = useLaunchStore();
|
||||
const inviteStore = useInviteStore();
|
||||
const { t } = useI18n();
|
||||
|
||||
instanceStore.createNewInstance(worldId).then((args) => {
|
||||
const location = args?.json?.location;
|
||||
if (!location) {
|
||||
toast.error(t('message.instance.create_failed'));
|
||||
return;
|
||||
}
|
||||
// self invite
|
||||
const L = parseLocation(location);
|
||||
if (!L.isRealInstance) {
|
||||
return;
|
||||
}
|
||||
if (inviteStore.canOpenInstanceInGame) {
|
||||
const secureOrShortName =
|
||||
args.json.shortName || args.json.secureName;
|
||||
launchStore.tryOpenInstanceInVrc(location, secureOrShortName);
|
||||
return;
|
||||
}
|
||||
instanceRequest
|
||||
.selfInvite({
|
||||
instanceId: L.instanceId,
|
||||
worldId: L.worldId
|
||||
})
|
||||
.then((args) => {
|
||||
toast.success(t('message.invite.self_sent'));
|
||||
return args;
|
||||
});
|
||||
});
|
||||
}
|
||||
189
src/coordinators/locationCoordinator.js
Normal file
189
src/coordinators/locationCoordinator.js
Normal file
@@ -0,0 +1,189 @@
|
||||
import {
|
||||
getGroupName,
|
||||
getWorldName,
|
||||
isRealInstance,
|
||||
parseLocation
|
||||
} from '../shared/utils';
|
||||
import { database } from '../service/database';
|
||||
import { useAdvancedSettingsStore } from '../stores/settings/advanced';
|
||||
import { useGameLogStore } from '../stores/gameLog';
|
||||
import { useGameStore } from '../stores/game';
|
||||
import { useInstanceStore } from '../stores/instance';
|
||||
import { useLocationStore } from '../stores/location';
|
||||
import { useNotificationStore } from '../stores/notification';
|
||||
import { usePhotonStore } from '../stores/photon';
|
||||
import { useUserStore } from '../stores/user';
|
||||
import { useVrStore } from '../stores/vr';
|
||||
|
||||
export function runUpdateCurrentUserLocationFlow() {
|
||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||
const userStore = useUserStore();
|
||||
const instanceStore = useInstanceStore();
|
||||
const gameStore = useGameStore();
|
||||
const locationStore = useLocationStore();
|
||||
|
||||
const ref = userStore.cachedUsers.get(userStore.currentUser.id);
|
||||
if (typeof ref === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
// update cached user with both gameLog and API locations
|
||||
let currentLocation = userStore.currentUser.$locationTag;
|
||||
const L = parseLocation(currentLocation);
|
||||
if (L.isTraveling) {
|
||||
currentLocation = userStore.currentUser.$travelingToLocation;
|
||||
}
|
||||
ref.location = userStore.currentUser.$locationTag;
|
||||
ref.travelingToLocation = userStore.currentUser.$travelingToLocation;
|
||||
|
||||
if (
|
||||
gameStore.isGameRunning &&
|
||||
!advancedSettingsStore.gameLogDisabled &&
|
||||
locationStore.lastLocation.location !== ''
|
||||
) {
|
||||
// use gameLog instead of API when game is running
|
||||
currentLocation = locationStore.lastLocation.location;
|
||||
if (locationStore.lastLocation.location === 'traveling') {
|
||||
currentLocation = locationStore.lastLocationDestination;
|
||||
}
|
||||
ref.location = locationStore.lastLocation.location;
|
||||
ref.travelingToLocation = locationStore.lastLocationDestination;
|
||||
}
|
||||
|
||||
ref.$online_for = userStore.currentUser.$online_for;
|
||||
ref.$offline_for = userStore.currentUser.$offline_for;
|
||||
ref.$location = parseLocation(currentLocation);
|
||||
if (!gameStore.isGameRunning || advancedSettingsStore.gameLogDisabled) {
|
||||
ref.$location_at = userStore.currentUser.$location_at;
|
||||
ref.$travelingToTime = userStore.currentUser.$travelingToTime;
|
||||
userStore.applyUserDialogLocation();
|
||||
instanceStore.applyWorldDialogInstances();
|
||||
instanceStore.applyGroupDialogInstances();
|
||||
} else {
|
||||
ref.$location_at = locationStore.lastLocation.date;
|
||||
ref.$travelingToTime = locationStore.lastLocationDestinationTime;
|
||||
userStore.setCurrentUserTravelingToTime(
|
||||
locationStore.lastLocationDestinationTime
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runSetCurrentUserLocationFlow(location, travelingToLocation) {
|
||||
const userStore = useUserStore();
|
||||
const instanceStore = useInstanceStore();
|
||||
const notificationStore = useNotificationStore();
|
||||
const gameStore = useGameStore();
|
||||
const gameLogStore = useGameLogStore();
|
||||
const locationStore = useLocationStore();
|
||||
|
||||
userStore.setCurrentUserLocationState(location, travelingToLocation);
|
||||
runUpdateCurrentUserLocationFlow();
|
||||
|
||||
// janky gameLog support for Quest
|
||||
if (gameStore.isGameRunning) {
|
||||
// with the current state of things, lets not run this if we don't need to
|
||||
return;
|
||||
}
|
||||
const lastLocationArray = await database.lookupGameLogDatabase(
|
||||
['Location'],
|
||||
[],
|
||||
1
|
||||
);
|
||||
const lastLocationTemp =
|
||||
lastLocationArray.length > 0 ? lastLocationArray[0].location : '';
|
||||
if (lastLocationTemp === location) {
|
||||
return;
|
||||
}
|
||||
locationStore.setLastLocationDestination('');
|
||||
locationStore.setLastLocationDestinationTime(0);
|
||||
|
||||
if (isRealInstance(location)) {
|
||||
const dt = new Date().toJSON();
|
||||
const L = parseLocation(location);
|
||||
|
||||
locationStore.setLastLocation({
|
||||
...locationStore.lastLocation,
|
||||
location,
|
||||
date: Date.now()
|
||||
});
|
||||
|
||||
const entry = {
|
||||
created_at: dt,
|
||||
type: 'Location',
|
||||
location,
|
||||
worldId: L.worldId,
|
||||
worldName: await getWorldName(L.worldId),
|
||||
groupName: await getGroupName(L.groupId),
|
||||
time: 0
|
||||
};
|
||||
database.addGamelogLocationToDatabase(entry);
|
||||
notificationStore.queueGameLogNoty(entry);
|
||||
gameLogStore.addGameLog(entry);
|
||||
instanceStore.addInstanceJoinHistory(location, dt);
|
||||
|
||||
userStore.applyUserDialogLocation();
|
||||
instanceStore.applyWorldDialogInstances();
|
||||
instanceStore.applyGroupDialogInstances();
|
||||
} else {
|
||||
locationStore.setLastLocation({
|
||||
...locationStore.lastLocation,
|
||||
location: '',
|
||||
date: null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function runLastLocationResetFlow(gameLogDate) {
|
||||
const photonStore = usePhotonStore();
|
||||
const instanceStore = useInstanceStore();
|
||||
const gameLogStore = useGameLogStore();
|
||||
const vrStore = useVrStore();
|
||||
const userStore = useUserStore();
|
||||
const locationStore = useLocationStore();
|
||||
|
||||
let dateTime = gameLogDate;
|
||||
if (!gameLogDate) {
|
||||
dateTime = new Date().toJSON();
|
||||
}
|
||||
const dateTimeStamp = Date.parse(dateTime);
|
||||
photonStore.resetLocationPhotonState();
|
||||
const playerList = Array.from(locationStore.lastLocation.playerList.values());
|
||||
const dataBaseEntries = [];
|
||||
for (const ref of playerList) {
|
||||
const entry = {
|
||||
created_at: dateTime,
|
||||
type: 'OnPlayerLeft',
|
||||
displayName: ref.displayName,
|
||||
location: locationStore.lastLocation.location,
|
||||
userId: ref.userId,
|
||||
time: dateTimeStamp - ref.joinTime
|
||||
};
|
||||
dataBaseEntries.unshift(entry);
|
||||
gameLogStore.addGameLog(entry);
|
||||
}
|
||||
database.addGamelogJoinLeaveBulk(dataBaseEntries);
|
||||
if (locationStore.lastLocation.date !== null && locationStore.lastLocation.date > 0) {
|
||||
const update = {
|
||||
time: dateTimeStamp - locationStore.lastLocation.date,
|
||||
created_at: new Date(locationStore.lastLocation.date).toJSON()
|
||||
};
|
||||
database.updateGamelogLocationTimeToDatabase(update);
|
||||
}
|
||||
locationStore.setLastLocationDestination('');
|
||||
locationStore.setLastLocationDestinationTime(0);
|
||||
locationStore.setLastLocation({
|
||||
date: 0,
|
||||
location: '',
|
||||
name: '',
|
||||
playerList: new Map(),
|
||||
friendList: new Map()
|
||||
});
|
||||
runUpdateCurrentUserLocationFlow();
|
||||
instanceStore.updateCurrentInstanceWorld();
|
||||
vrStore.updateVRLastLocation();
|
||||
instanceStore.getCurrentInstanceUserList();
|
||||
gameLogStore.resetLastMediaUrls();
|
||||
userStore.applyUserDialogLocation();
|
||||
instanceStore.applyWorldDialogInstances();
|
||||
instanceStore.applyGroupDialogInstances();
|
||||
}
|
||||
45
src/coordinators/moderationCoordinator.js
Normal file
45
src/coordinators/moderationCoordinator.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { avatarModerationRequest, playerModerationRequest } from '../api';
|
||||
import { useAvatarStore } from '../stores/avatar';
|
||||
import { useModerationStore } from '../stores/moderation';
|
||||
|
||||
/**
|
||||
* Refreshes all player and avatar moderations from the API.
|
||||
* Orchestrates across moderation store and avatar store.
|
||||
*/
|
||||
export async function runRefreshPlayerModerationsFlow() {
|
||||
const moderationStore = useModerationStore();
|
||||
const avatarStore = useAvatarStore();
|
||||
|
||||
if (moderationStore.playerModerationTable.loading) {
|
||||
return;
|
||||
}
|
||||
moderationStore.playerModerationTable.loading = true;
|
||||
moderationStore.expirePlayerModerations();
|
||||
Promise.all([
|
||||
playerModerationRequest.getPlayerModerations(),
|
||||
avatarModerationRequest.getAvatarModerations()
|
||||
])
|
||||
.finally(() => {
|
||||
moderationStore.playerModerationTable.loading = false;
|
||||
})
|
||||
.then((res) => {
|
||||
avatarStore.resetCachedAvatarModerations();
|
||||
if (res[1]?.json) {
|
||||
for (const json of res[1].json) {
|
||||
avatarStore.applyAvatarModeration(json);
|
||||
}
|
||||
}
|
||||
if (res[0]?.json) {
|
||||
for (let json of res[0].json) {
|
||||
moderationStore.applyPlayerModeration(json);
|
||||
}
|
||||
}
|
||||
moderationStore.deleteExpiredPlayerModerations();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(
|
||||
'Failed to load player/avatar moderations:',
|
||||
error
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import { useFriendStore } from '../stores/friend';
|
||||
import { useGeneralSettingsStore } from '../stores/settings/general';
|
||||
import { useGroupStore } from '../stores/group';
|
||||
import { useInstanceStore } from '../stores/instance';
|
||||
import { useNotificationStore } from '../stores/notification';
|
||||
import { useSharedFeedStore } from '../stores/sharedFeed';
|
||||
import { useUserStore } from '../stores/user';
|
||||
import { useWorldStore } from '../stores/world';
|
||||
|
||||
@@ -30,6 +32,8 @@ export async function runHandleUserUpdateFlow(
|
||||
const groupStore = useGroupStore();
|
||||
const instanceStore = useInstanceStore();
|
||||
const feedStore = useFeedStore();
|
||||
const notificationStore = useNotificationStore();
|
||||
const sharedFeedStore = useSharedFeedStore();
|
||||
const avatarStore = useAvatarStore();
|
||||
const generalSettingsStore = useGeneralSettingsStore();
|
||||
|
||||
@@ -139,7 +143,9 @@ export async function runHandleUserUpdateFlow(
|
||||
previousLocation,
|
||||
time
|
||||
};
|
||||
feedStore.addFeed(feed);
|
||||
notificationStore.queueFeedNoty(feed);
|
||||
sharedFeedStore.addEntry(feed);
|
||||
feedStore.addFeedEntry(feed);
|
||||
database.addGPSToDatabase(feed);
|
||||
// clear previousLocation after GPS
|
||||
ref.$previousLocation = '';
|
||||
@@ -249,7 +255,9 @@ export async function runHandleUserUpdateFlow(
|
||||
currentAvatarTags,
|
||||
previousCurrentAvatarTags
|
||||
};
|
||||
feedStore.addFeed(feed);
|
||||
notificationStore.queueFeedNoty(feed);
|
||||
sharedFeedStore.addEntry(feed);
|
||||
feedStore.addFeedEntry(feed);
|
||||
database.addAvatarToDatabase(feed);
|
||||
}
|
||||
}
|
||||
@@ -296,7 +304,9 @@ export async function runHandleUserUpdateFlow(
|
||||
previousStatus,
|
||||
previousStatusDescription
|
||||
};
|
||||
feedStore.addFeed(feed);
|
||||
notificationStore.queueFeedNoty(feed);
|
||||
sharedFeedStore.addEntry(feed);
|
||||
feedStore.addFeedEntry(feed);
|
||||
database.addStatusToDatabase(feed);
|
||||
}
|
||||
if (props.bio && props.bio[0] && props.bio[1]) {
|
||||
@@ -316,7 +326,9 @@ export async function runHandleUserUpdateFlow(
|
||||
bio,
|
||||
previousBio
|
||||
};
|
||||
feedStore.addFeed(feed);
|
||||
notificationStore.queueFeedNoty(feed);
|
||||
sharedFeedStore.addEntry(feed);
|
||||
feedStore.addFeedEntry(feed);
|
||||
database.addBioToDatabase(feed);
|
||||
}
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user