Refactor Discord RPC

This commit is contained in:
Natsumi
2025-08-01 17:06:13 +12:00
parent 7946ff63ae
commit bc2211f332
7 changed files with 332 additions and 274 deletions

View File

@@ -28,22 +28,12 @@ export const useLocationStore = defineStore('Location', () => {
const state = reactive({
lastLocation: {
date: 0,
date: null,
location: '',
name: '',
playerList: new Map(),
friendList: new Map()
},
lastLocation$: {
tag: '',
instanceId: '',
accessType: '',
worldName: '',
worldCapacity: 0,
joinUrl: '',
statusName: '',
statusImage: ''
},
lastLocationDestination: '',
lastLocationDestinationTime: 0
});
@@ -55,13 +45,6 @@ export const useLocationStore = defineStore('Location', () => {
}
});
const lastLocation$ = computed({
get: () => state.lastLocation$,
set: (value) => {
state.lastLocation$ = value;
}
});
const lastLocationDestination = computed({
get: () => state.lastLocationDestination,
set: (value) => {
@@ -153,7 +136,7 @@ export const useLocationStore = defineStore('Location', () => {
const L = parseLocation(location);
state.lastLocation.location = location;
state.lastLocation.date = dt;
state.lastLocation.date = Date.now();
const entry = {
created_at: dt,
@@ -174,7 +157,7 @@ export const useLocationStore = defineStore('Location', () => {
instanceStore.applyGroupDialogInstances();
} else {
state.lastLocation.location = '';
state.lastLocation.date = '';
state.lastLocation.date = null;
}
}
@@ -218,7 +201,7 @@ export const useLocationStore = defineStore('Location', () => {
gameLogStore.addGameLog(entry);
}
database.addGamelogJoinLeaveBulk(dataBaseEntries);
if (state.lastLocation.date !== 0) {
if (state.lastLocation.date !== null && state.lastLocation.date > 0) {
const update = {
time: dateTimeStamp - state.lastLocation.date,
created_at: new Date(state.lastLocation.date).toJSON()
@@ -248,7 +231,6 @@ export const useLocationStore = defineStore('Location', () => {
return {
state,
lastLocation,
lastLocation$,
lastLocationDestination,
lastLocationDestinationTime,
updateCurrentUserLocation,