Add a button to open the preferences window in the Discord setup window

This commit is contained in:
Samuel Elliott
2022-09-07 16:12:13 +01:00
parent 5236536222
commit 0421f5e565
4 changed files with 20 additions and 1 deletions

View File

@@ -9,6 +9,8 @@ import { getAccounts, RequestState, Root, useAsync, useDiscordPresenceSource, us
export interface DiscordSetupProps {
users?: string[];
friend_nsa_id?: string;
/** @default true */
show_preferences_button?: boolean;
}
enum DiscordSourceType {
@@ -158,6 +160,15 @@ export default function DiscordSetup(props: DiscordSetupProps) {
style={[styles.textInput, theme.textInput]} />
</> : null}
{discord_presence_source && (props.show_preferences_button ?? true) ? <>
<Text style={[styles.help, styles.header, theme.text]}>Configure additional options for Discord Rich Presence</Text>
<View style={[styles.button, styles.buttonPreferences]}>
<Button title="Preferences"
onPress={() => ipc.showPreferencesWindow()}
color={'#' + (accent_colour ?? DEFAULT_ACCENT_COLOUR)} />
</View>
</> : null}
<View style={styles.buttons}>
<View style={styles.button}>
<Button title="Cancel"
@@ -222,6 +233,12 @@ const styles = StyleSheet.create({
button: {
marginLeft: 10,
},
buttonPreferences: {
marginTop: 10,
marginLeft: 0,
flexDirection: 'row',
justifyContent: 'flex-start',
},
});
const light = StyleSheet.create({

View File

@@ -159,7 +159,7 @@ export default function Preferences(props: PreferencesProps) {
<View style={styles.button}>
<Button title="Discord Rich Presence setup"
onPress={() => ipc.showDiscordModal()}
onPress={() => ipc.showDiscordModal({show_preferences_button: false})}
color={'#' + (accent_colour ?? DEFAULT_ACCENT_COLOUR)} />
</View>

View File

@@ -83,6 +83,7 @@ export function setupIpc(appinstance: App, ipcMain: IpcMain) {
ipcMain.handle('nxapi:coral:friendcode', (e, token: string, friendcode: string, hash?: string) => store.users.get(token).then(u => u.nso.getUserByFriendCode(friendcode, hash)).then(r => r.result));
ipcMain.handle('nxapi:coral:addfriend', (e, token: string, nsaid: string) => store.users.get(token).then(u => u.addFriend(nsaid)));
ipcMain.handle('nxapi:window:showpreferences', () => appinstance.showPreferencesWindow().id);
ipcMain.handle('nxapi:window:showfriend', (e, props: FriendProps) => createWindow(WindowType.FRIEND, props, {
parent: BrowserWindow.fromWebContents(e.sender) ?? undefined,
modal: true,

View File

@@ -65,6 +65,7 @@ const ipc = {
getNintendoAccountMoonToken: (id: string) => inv<string | undefined>('moon:gettoken', id),
getSavedMoonToken: (token: string) => inv<SavedMoonToken | undefined>('moon:getcachedtoken', token),
showPreferencesWindow: () => inv<number>('window:showpreferences'),
showFriendModal: (props: FriendProps) => inv<number>('window:showfriend', props),
showDiscordModal: (props: DiscordSetupProps = {}) => inv<number>('window:discord', props),
showAddFriendModal: (props: AddFriendProps) => inv<number>('window:addfriend', props),