feat(desktop): report current user online clients
This commit is contained in:
@@ -203,6 +203,7 @@ export interface RuntimeControllerSnapshot {
|
||||
lastPullStatus: 'idle' | 'success' | 'failed'
|
||||
lastAccountsSyncAt: number
|
||||
lastServerTime: string | null
|
||||
onlineClientCount: number | null
|
||||
lastError: string | null
|
||||
}
|
||||
|
||||
@@ -251,6 +252,7 @@ interface RuntimeState {
|
||||
lastPullStatus: 'idle' | 'success' | 'failed'
|
||||
lastAccountsSyncAt: number
|
||||
lastServerTime: string | null
|
||||
onlineClientCount: number | null
|
||||
lastError: string | null
|
||||
activitySeq: number
|
||||
}
|
||||
@@ -280,6 +282,7 @@ const state: RuntimeState = {
|
||||
lastPullStatus: 'idle',
|
||||
lastAccountsSyncAt: 0,
|
||||
lastServerTime: null,
|
||||
onlineClientCount: null,
|
||||
lastError: null,
|
||||
activitySeq: 0,
|
||||
}
|
||||
@@ -532,6 +535,7 @@ export function getRuntimeControllerSnapshot(): RuntimeControllerSnapshot {
|
||||
lastPullStatus: state.lastPullStatus,
|
||||
lastAccountsSyncAt: state.lastAccountsSyncAt,
|
||||
lastServerTime: state.lastServerTime,
|
||||
onlineClientCount: state.onlineClientCount,
|
||||
lastError: state.lastError,
|
||||
}
|
||||
}
|
||||
@@ -627,6 +631,7 @@ function clearRuntimeState(): void {
|
||||
state.lastPullStatus = 'idle'
|
||||
state.lastAccountsSyncAt = 0
|
||||
state.lastServerTime = null
|
||||
state.onlineClientCount = null
|
||||
state.lastError = null
|
||||
state.publishFallbackBackoffUntil = 0
|
||||
setSchedulerQueueDepth(localQueueDepth())
|
||||
@@ -977,6 +982,8 @@ async function sendHeartbeat(source: 'startup' | 'timer'): Promise<void> {
|
||||
state.lastHeartbeatAt = Date.now()
|
||||
state.lastHeartbeatStatus = 'success'
|
||||
state.lastServerTime = response.server_time
|
||||
state.onlineClientCount =
|
||||
response.current_user_online_client_count ?? response.online_client_count ?? null
|
||||
state.lastError = null
|
||||
|
||||
noteTransportHeartbeat(true)
|
||||
|
||||
@@ -144,6 +144,10 @@ function createLiveRuntimeSnapshot(controller: RuntimeControllerSnapshot) {
|
||||
channel: controller.client?.channel ?? 'dev',
|
||||
},
|
||||
] as const
|
||||
const onlineClientCount =
|
||||
typeof controller.onlineClientCount === 'number'
|
||||
? Math.max(0, controller.onlineClientCount)
|
||||
: clients.filter((item) => item.status === 'online').length
|
||||
|
||||
const accounts = controller.accounts.map((account) =>
|
||||
createRuntimeAccountView(controller, account, {
|
||||
@@ -185,7 +189,7 @@ function createLiveRuntimeSnapshot(controller: RuntimeControllerSnapshot) {
|
||||
lastFullSyncAt: controller.lastAccountsSyncAt || now,
|
||||
},
|
||||
summary: {
|
||||
onlineClients: clients.filter((item) => item.status === 'online').length,
|
||||
onlineClients: onlineClientCount,
|
||||
accountsBound: accounts.length,
|
||||
queuedTasks: tasks.filter((item) => item.status === 'queued').length,
|
||||
issuesOpen:
|
||||
|
||||
@@ -53,7 +53,7 @@ const subsystemEntries = computed(() =>
|
||||
})),
|
||||
)
|
||||
|
||||
const clientCount = computed(() => snapshot.value?.clients.length ?? 0)
|
||||
const clientCount = computed(() => snapshot.value?.summary.onlineClients ?? 0)
|
||||
const appVersion = computed(() => snapshot.value?.app.version ?? '0.1.0')
|
||||
const hasServerSettingChanged = computed(
|
||||
() => normalizeServerURLInput(serverBaseURL.value) !== apiBaseURL.value,
|
||||
|
||||
Reference in New Issue
Block a user