This commit is contained in:
2026-10-18 18:00:12 +07:00
parent e881f10857
commit a3317dbf7a
11 changed files with 834 additions and 445 deletions
+18 -2
View File
@@ -1171,6 +1171,7 @@ export class Online {
login: 'Вход на сервер…',
logout: 'Выход из аккаунта…',
games: 'Загрузка списка игр…',
'select-game': 'Подготовка выбранной игры…',
connect: 'Подключение игры…',
disconnect: 'Отключение игры…',
download: 'Загрузка материалов игры…',
@@ -1278,10 +1279,13 @@ export class Online {
return
case 'games':
return this.loadGames()
case 'select-game':
case 'download':
case 'check': {
const gameId = integer(data.gameId, 1)
const key = packageKey(this.state.server, gameId)
if (action === 'select-game' && this.controller.state.outputOpen)
throw new Error('Закройте показ перед выбором игры')
if (
action === 'download' &&
key === this.controller.state.catalog.key &&
@@ -1289,7 +1293,7 @@ export class Online {
)
throw new Error('Закройте показ перед обновлением выбранной игры')
if (!this.credentials) throw new ApiError(401)
this.downloadKey = action === 'download' ? key : null
this.downloadKey = action === 'check' ? null : key
this.cancellation = new AbortController()
this.state.canCancel = true
try {
@@ -1324,7 +1328,8 @@ export class Online {
},
})
this.state.packagesRevision++
if (key === this.controller.state.catalog.key) {
if (action === 'select-game' || key === this.controller.state.catalog.key) {
if (action === 'select-game') this.detach()
this.controller.selectPackage(pkg)
this.plan = {
steps: structuredClone(this.controller.state.catalog.steps),
@@ -1335,6 +1340,10 @@ export class Online {
await this.atomic(`plan-${key}.json`, this.cachedPlan)
this.previous = null
await this.restoreResults(key)
if (action === 'select-game') {
await this.saveSelection()
await this.persistSecrets()
}
}
this.state.notice = 'Материалы проверены и готовы к показу'
} finally {
@@ -1406,6 +1415,13 @@ export class Online {
return
}
case 'disconnect':
if (this.screen) {
try {
await this.client().UnbindScreen({ screenID: this.screen.id })
} catch (error) {
if (!(error instanceof ApiError && error.status === 404)) throw error
}
}
this.detach()
await this.persistSecrets()
return