mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-08-20 01:25:31 -05:00
Add a button to open the preferences window in the Discord setup window
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user