From 116bae844acdff123292f08ed11e1a7d8a2c3890 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Fri, 1 Aug 2025 22:30:27 +0100 Subject: [PATCH] Show platform in app --- src/app/browser/friend/index.tsx | 8 ++++++-- src/app/i18n/locale/de-de.ts | 4 ++++ src/app/i18n/locale/en-gb.ts | 4 ++++ src/app/i18n/locale/es-es.ts | 4 ++++ src/app/i18n/locale/ja-jp.ts | 4 ++++ src/app/main/ipc.ts | 9 +++++++-- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/app/browser/friend/index.tsx b/src/app/browser/friend/index.tsx index 54570af..7e80963 100644 --- a/src/app/browser/friend/index.tsx +++ b/src/app/browser/friend/index.tsx @@ -4,7 +4,7 @@ import React, { useCallback, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { ActivityIndicator, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { CheckBox } from 'react-native-web'; -import { Friend, Presence, PresenceGame, PresencePermissions, PresenceState } from '../../../api/coral-types.js'; +import { Friend, Presence, PresenceGame, PresencePermissions, PresencePlatform, PresenceState } from '../../../api/coral-types.js'; import { getTitleIdFromEcUrl, hrduration } from '../../../util/misc.js'; import { Button } from '../components/index.js'; import { DEFAULT_ACCENT_COLOUR, TEXT_COLOUR_ACTIVE, TEXT_COLOUR_DARK, TEXT_COLOUR_LIGHT } from '../constants.js'; @@ -164,7 +164,11 @@ function FriendPresence(props: { const game = 'name' in props.presence.game ? props.presence.game : null; if ((props.presence.state === PresenceState.ONLINE || props.presence.state === PresenceState.PLAYING) && game) { - return {t('presence_playing', {game: game.name})}; + return {t( + 'platform' in props.presence ? + props.presence.platform === PresencePlatform.NX ? 'presence_playing_nx' : + props.presence.platform === PresencePlatform.OUNCE ? 'presence_playing_ounce' : + 'presence_playing' : 'presence_playing', {game: game.name})}; } return diff --git a/src/app/i18n/locale/de-de.ts b/src/app/i18n/locale/de-de.ts index 11e649f..187a0ec 100644 --- a/src/app/i18n/locale/de-de.ts +++ b/src/app/i18n/locale/de-de.ts @@ -68,6 +68,8 @@ export const menus = { friend: { presence_online: 'Online', + presence_online_nx: 'Online (Nintendo Switch)', + presence_online_ounce: 'Online (Nintendo Switch 2)', game_first_played: 'Zuerst gespielt: {{date, datetime}}', game_play_time_h: 'Spielzeit: $t(friend.hours, {"count": {{hours}}})', @@ -305,6 +307,8 @@ export const friend_window = { close: 'Schließen', presence_playing: 'Spielt {{game}}', + presence_playing_nx: 'Spielt {{game}} (Nintendo Switch)', + presence_playing_ounce: 'Spielt {{game}} (Nintendo Switch 2)', presence_offline: 'Offline', presence_last_seen: 'Zuletzt gesehen: {{since_logout}}', diff --git a/src/app/i18n/locale/en-gb.ts b/src/app/i18n/locale/en-gb.ts index 395e5b4..4492354 100644 --- a/src/app/i18n/locale/en-gb.ts +++ b/src/app/i18n/locale/en-gb.ts @@ -69,6 +69,8 @@ export const menus = { friend: { presence_online: 'Online', + presence_online_nx: 'Online (Nintendo Switch)', + presence_online_ounce: 'Online (Nintendo Switch 2)', game_first_played: 'First played: {{date, datetime}}', game_play_time_h: 'Play time: $t(friend.hours, {"count": {{hours}}})', @@ -310,6 +312,8 @@ export const friend_window = { close: 'Close', presence_playing: 'Playing {{game}}', + presence_playing_nx: 'Playing {{game}} (Nintendo Switch)', + presence_playing_ounce: 'Playing {{game}} (Nintendo Switch 2)', presence_offline: 'Offline', presence_last_seen: 'Last seen {{since_logout}}', diff --git a/src/app/i18n/locale/es-es.ts b/src/app/i18n/locale/es-es.ts index e40e05c..7c1ba45 100644 --- a/src/app/i18n/locale/es-es.ts +++ b/src/app/i18n/locale/es-es.ts @@ -68,6 +68,8 @@ export const menus = { friend: { presence_online: 'Online', + presence_online_nx: 'Online (Nintendo Switch)', + presence_online_ounce: 'Online (Nintendo Switch 2)', game_first_played: 'Jugado por primera vez: {{date, datetime}}', game_play_time_h: 'Tiempo de juego: $t(friend.hours, {"count": {{hours}}})', @@ -306,6 +308,8 @@ export const friend_window = { close: 'Cerrar', presence_playing: 'Jugando {{game}}', + presence_playing_nx: 'Jugando {{game}} (Nintendo Switch)', + presence_playing_ounce: 'Jugando {{game}} (Nintendo Switch 2)', presence_offline: 'Desconectado', presence_last_seen: 'Visto por última vez: {{since_logout}}', diff --git a/src/app/i18n/locale/ja-jp.ts b/src/app/i18n/locale/ja-jp.ts index 0214beb..eac8943 100644 --- a/src/app/i18n/locale/ja-jp.ts +++ b/src/app/i18n/locale/ja-jp.ts @@ -68,6 +68,8 @@ export const menus = { friend: { presence_online: 'オンライン', + presence_online_nx: 'オンライン (Nintendo Switch)', + presence_online_ounce: 'オンライン (Nintendo Switch 2)', game_first_played: '初めてあそんだ日: {{date, datetime}}', game_play_time_h: 'プレイ時間: $t(friend.hours, {"count": {{hours}}})', @@ -273,6 +275,8 @@ export const friend_window = { close: '閉じる', presence_playing: '{{game}}をプレイ中', + presence_playing_nx: '{{game}}をプレイ中 (Nintendo Switch)', + presence_playing_ounce: '{{game}}をプレイ中 (Nintendo Switch 2)', presence_offline: 'オフライン', presence_last_seen: '最終ログイン: {{since_logout}}', diff --git a/src/app/main/ipc.ts b/src/app/main/ipc.ts index 8473699..7a0c94b 100644 --- a/src/app/main/ipc.ts +++ b/src/app/main/ipc.ts @@ -9,7 +9,7 @@ import { askAddNsoAccount, askAddPctlAccount } from './na-auth.js'; import { App } from './index.js'; import { EmbeddedPresenceMonitor } from './monitor.js'; import { DiscordPresenceConfiguration, DiscordPresenceSource, DiscordStatus, LoginItemOptions, WindowType } from '../common/types.js'; -import { CurrentUser, Friend, Game, PresenceState, WebService } from '../../api/coral-types.js'; +import { CurrentUser, Friend, Game, PresencePlatform, PresenceState, WebService } from '../../api/coral-types.js'; import { NintendoAccountSessionTokenJwtPayload, NintendoAccountUser } from '../../api/na.js'; import { DiscordPresence } from '../../discord/types.js'; import { getDiscordRpcClients } from '../../discord/rpc.js'; @@ -313,7 +313,12 @@ function buildFriendMenu(app: App, user: NintendoAccountUser, nso: CurrentUser, return Menu.buildFromTemplate([ ...(!friend.presence.updatedAt ? [ ] : friend.presence.state === PresenceState.ONLINE || friend.presence.state === PresenceState.PLAYING ? [ - new MenuItem({label: t('presence_online')!, enabled: false}), + new MenuItem({label: t( + 'platform' in friend.presence ? + friend.presence.platform === PresencePlatform.NX ? 'presence_online_nx' : + friend.presence.platform === PresencePlatform.OUNCE ? 'presence_online_ounce' : + 'presence_online' : + 'presence_online')!, enabled: false}), ...('name' in friend.presence.game ? [ new MenuItem({label: friend.presence.game.name, click: () => shell.openExternal((friend.presence.game as Game).shopUri)}),