diff --git a/apps/mobile-rn/__tests__/devices.test.ts b/apps/mobile-rn/__tests__/devices.test.ts index f7e45a4..dccf1a6 100644 --- a/apps/mobile-rn/__tests__/devices.test.ts +++ b/apps/mobile-rn/__tests__/devices.test.ts @@ -27,6 +27,12 @@ describe('device response contract', () => { }) }) + it('accepts desktop and web devices registered to the same account', () => { + for (const platform of ['windows', 'macos', 'web', 'ios'] as const) { + expect(normalizeRegisteredDevice({ ...row, platform }).platform).toBe(platform) + } + }) + it('rejects missing timestamps and unsupported platforms', () => { expect(() => normalizeRegisteredDevice({ ...row, last_seen_at: 'bad' })) .toThrow(DeviceServiceError) diff --git a/apps/mobile-rn/src/features/devices/device-service.ts b/apps/mobile-rn/src/features/devices/device-service.ts index 597c400..b05d8fa 100644 --- a/apps/mobile-rn/src/features/devices/device-service.ts +++ b/apps/mobile-rn/src/features/devices/device-service.ts @@ -1,11 +1,19 @@ import type { MobileRuntimeConfig } from '../../lib/native-config' import { supabase } from '../../lib/supabase' +/** 서버 devices.platform CHECK 목록과 같다. 데스크톱(windows/macos)도 같은 계정의 기기로 등록된다. */ +export const DEVICE_PLATFORMS = ['android', 'ios', 'web', 'windows', 'macos'] as const +export type DevicePlatform = (typeof DEVICE_PLATFORMS)[number] + +function isDevicePlatform(value: unknown): value is DevicePlatform { + return typeof value === 'string' && (DEVICE_PLATFORMS as readonly string[]).includes(value) +} + export interface RegisteredDevice { id: string userId: string installationId: string - platform: 'android' | 'ios' + platform: DevicePlatform deviceName: string appVersion: string osVersion: string | null @@ -43,7 +51,7 @@ export function normalizeRegisteredDevice(value: unknown): RegisteredDevice { typeof value.id !== 'string' || typeof value.user_id !== 'string' || typeof value.installation_id !== 'string' - || (value.platform !== 'android' && value.platform !== 'ios') + || !isDevicePlatform(value.platform) || typeof value.device_name !== 'string' || typeof value.app_version !== 'string' || (value.os_version !== null && typeof value.os_version !== 'string') diff --git a/apps/mobile-rn/src/screens/DevicesScreen.tsx b/apps/mobile-rn/src/screens/DevicesScreen.tsx index b370548..d372d17 100644 --- a/apps/mobile-rn/src/screens/DevicesScreen.tsx +++ b/apps/mobile-rn/src/screens/DevicesScreen.tsx @@ -150,7 +150,10 @@ export default function DevicesScreen(): React.ReactElement { : t('mobile.devices.active')} - {device.osVersion ?? '—'} + + {t(`mobile.devices.platform.${device.platform}`)} + {device.osVersion ? ` · ${device.osVersion}` : ''} + {t('mobile.devices.version', { version: device.appVersion })}