diff --git a/app/package-lock.json b/app/package-lock.json index 844c287..23f0e68 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "gvr-app", - "version": "1.11.0", + "version": "1.11.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gvr-app", - "version": "1.11.0", + "version": "1.11.1", "license": "UNLICENSED", "dependencies": { "@discordjs/voice": "^0.19.2", diff --git a/app/package.json b/app/package.json index 5addc74..57394e4 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "gvr-app", "productName": "겜녹이", - "version": "1.11.0", + "version": "1.11.1", "description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록", "private": true, "main": "dist/main.cjs", diff --git a/app/src/core/util/events.ts b/app/src/core/util/events.ts index 48b2cc8..910ff8a 100644 --- a/app/src/core/util/events.ts +++ b/app/src/core/util/events.ts @@ -5,8 +5,11 @@ import type { LiveEvent, User } from '@gvr/shared'; export class Bus extends EventEmitter { /** 'users.updated' 에 실을 유저 목록. 보내는 쪽은 신호만 주고 목록은 여기서 채운다 (빈 목록이 나가면 사이트에서 모든 발화가 "알 수 없음"이 됨) */ usersProvider: (() => User[]) | null = null; + /** 'users.updated' 를 보낸 횟수: 앱 설정 창이 바뀐 것을 알고 유저 목록을 다시 받는다 (Riot ID 자동 갱신 등, v1.11.1) */ + usersRev = 0; live(ev: LiveEvent): void { + if (ev.type === 'users.updated') this.usersRev++; if (ev.type === 'users.updated' && this.usersProvider) ev = { type: 'users.updated', data: this.usersProvider() }; this.emit('live', ev); } diff --git a/app/src/main/api-types.ts b/app/src/main/api-types.ts index b7755a4..7ee1da2 100644 --- a/app/src/main/api-types.ts +++ b/app/src/main/api-types.ts @@ -69,6 +69,8 @@ export interface AppState { /** 지금 게임 상태 (v1.3.6~) */ liveGames?: LiveGame[]; counts: { utterances: number; matches: number }; + /** 유저 목록이 바뀐 횟수 (바뀌면 게임 연동 탭 Riot ID 표를 다시 받는다, v1.11.1) */ + usersRev: number; excludedUsers: { id: string; name: string }[]; autoStart: boolean; } diff --git a/app/src/main/ipc.ts b/app/src/main/ipc.ts index 5fa799c..1f0324c 100644 --- a/app/src/main/ipc.ts +++ b/app/src/main/ipc.ts @@ -33,6 +33,7 @@ export function buildState(core: Core, opts: { dataDir: string; portable: boolea games: core.games.status() as AppState['games'], liveGames: core.games.live(), counts: core.store.counts(), + usersRev: core.bus.usersRev, excludedUsers: core.store .listUsers() .filter((u) => u.excluded) diff --git a/app/src/renderer/mock-gvr.ts b/app/src/renderer/mock-gvr.ts index a986624..96bae5a 100644 --- a/app/src/renderer/mock-gvr.ts +++ b/app/src/renderer/mock-gvr.ts @@ -173,6 +173,7 @@ export function createMockGvr(): GvrApi { }, ], counts: { utterances: 1824, matches: 37 }, + usersRev: 0, excludedUsers: noToken ? [] : [{ id: 'u4', name: '현우' }], autoStart: false, }; @@ -252,6 +253,14 @@ export function createMockGvr(): GvrApi { listeners.forEach((l) => l(snap)); }; + // 앱이 Riot ID 를 바꾼 것 흉내 (닉네임 · 태그를 바꾼 사람): 콘솔에서 __gvrMockRename('u1', '새이름#KR9') + (window as any).__gvrMockRename = (userId: string, riotId: string) => { + const u = users.find((x) => x.id === userId); + if (u?.riot[0]) u.riot[0].riotId = riotId; + state.usersRev++; + emit(); + }; + // 녹음 참가자/대기열이 조금씩 바뀌는 흉내 setInterval(() => { state.stt.queue = Math.random() < 0.7 ? 0 : Math.floor(Math.random() * 3); diff --git a/app/src/renderer/tabs/GamesTab.tsx b/app/src/renderer/tabs/GamesTab.tsx index 5cdd39f..3346ce7 100644 --- a/app/src/renderer/tabs/GamesTab.tsx +++ b/app/src/renderer/tabs/GamesTab.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { GAME_NAME, historyStatus, liveGameRows, resumeText, type LiveGame, type User } from '@gvr/shared'; import { gvr, useAction, useApp, useLoad } from '../store'; import { Avatar, Btn, Dot, Err, FolderRow, Page, Section, Spinner, Toggle } from '../ui'; @@ -126,8 +126,9 @@ const RIOT_RE = /^[^#]{1,16}#[^#\s]{2,5}$/; function RiotRow({ u }: { u: User }) { const { toast } = useApp(); + const server = u.riot.map((r) => r.riotId).join(','); const [v, setV] = useState(u.riot.map((r) => r.riotId).join(', ')); - const [saved, setSaved] = useState(u.riot.map((r) => r.riotId).join(',')); + const [saved, setSaved] = useState(server); const act = useAction(); const ids = v .split(',') @@ -135,6 +136,13 @@ function RiotRow({ u }: { u: User }) { .filter(Boolean); const bad = ids.filter((s) => !RIOT_RE.test(s)); const dirty = ids.join(',') !== saved; + // 앱이 Riot ID 를 바꾸면(닉네임 · 태그를 바꾼 사람, v1.11.1) 입력칸도 새 값으로. 고치는 중인 칸은 그대로 둔다 + useEffect(() => { + if (server === saved || dirty) return; + setV(u.riot.map((r) => r.riotId).join(', ')); + setSaved(server); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [server]); const savedCount = saved ? saved.split(',').length : 0; const commit = async () => { if (!dirty || bad.length) return; @@ -210,9 +218,10 @@ function RiotKey() { } export function GamesTab() { - const { settings, save } = useApp(); + const { settings, save, state } = useApp(); const g = settings.games; - const users = useLoad(() => gvr.users()); + // 앱이 유저 목록을 바꾸면(Riot ID 자동 갱신 · 녹음 중 새 사람 등) 다시 받는다 + const users = useLoad(() => gvr.users(), [state.usersRev]); return ( diff --git a/app/test/games.test.ts b/app/test/games.test.ts index faecaef..14c6903 100644 --- a/app/test/games.test.ts +++ b/app/test/games.test.ts @@ -94,10 +94,12 @@ test('발로란트·롤 어댑터: 가짜 Riot 서버로 경기 시작→채팅 store.upsertUser({ id: 'friend', name: '민수', avatar: null }); store.setAccounts('friend', [{ puuid: 'riotid:아직모름#KR1', riotId: '아직모름#KR1' }]); const before = live.filter((e) => e.type === 'users.updated').length; + const revBefore = bus.usersRev; mock.st.names = { 'self-puuid-0001': ['새하늘', 'KR2'] }; await until(() => store.listAccounts().some((a) => a.puuid === 'self-puuid-0001' && a.riot_id === '새하늘#KR2'), 5000, 'rename'); assert.equal(store.userIdForPuuid('self-puuid-0001'), 'owner'); assert.ok(live.filter((e) => e.type === 'users.updated').length > before, '사이트에 유저 목록 다시 보냄'); + assert.ok(bus.usersRev > revBefore, '앱 설정 창도 유저 목록을 다시 받게 (state.usersRev)'); assert.ok(store.listAccounts().some((a) => a.user_id === 'friend' && a.riot_id === '아직모름#KR1'), 'puuid 모르는 계정은 그대로'); // ---- 롤