Show platform in app

This commit is contained in:
Samuel Elliott 2025-08-01 22:30:27 +01:00
parent d00c988220
commit 116bae844a
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
6 changed files with 29 additions and 4 deletions

View File

@ -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 <Text style={[styles.presenceText, theme.text, styles.presenceTextOnline]}>{t('presence_playing', {game: game.name})}</Text>;
return <Text style={[styles.presenceText, theme.text, styles.presenceTextOnline]}>{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})}</Text>;
}
return <View>

View File

@ -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}}',

View File

@ -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}}',

View File

@ -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}}',

View File

@ -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}}',

View File

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