앱 게임 연동 탭 Riot ID 표: 앱이 유저 목록을 바꾸면(users.updated → state.usersRev) 다시 받고, 고치는 중이 아닌 입력칸은 새 Riot ID 로 맞춤 (탭을 열어 둔 채 자동 갱신된 이름이 보이게) · 목 __gvrMockRename · 시험 · v1.11.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-21 07:35:37 +09:00
parent c86c3ee8de
commit 673f2423d5
8 changed files with 33 additions and 7 deletions

4
app/package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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);

View File

@@ -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 (
<Page title="게임 연동">
<GameCards />

View File

@@ -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 모르는 계정은 그대로');
// ---- 롤