@@ -6,20 +6,36 @@ import React from "react";
66import { errSignal , trace } from "." ;
77import { updateActivity } from "./updateActivity" ;
88
9+ export enum PresenceStatus {
10+ Tidal = 0 ,
11+ Artist = 1 ,
12+ Track = 2 ,
13+ Custom = 3
14+ }
15+
16+ export enum CustomStatusPosition {
17+ ReplaceAppName = 0 ,
18+ ReplaceTrackName = 1
19+ }
20+
921export const settings = await ReactiveStore . getPluginStorage ( "DiscordRPC" , {
1022 displayOnPause : true ,
1123 displayArtistIcon : true ,
1224 displayPlaylistButton : true ,
13- status : 1 ,
14- customStatusText : ""
25+ status : PresenceStatus . Artist ,
26+ customStatusText : "" ,
27+ customStatusPosition : CustomStatusPosition . ReplaceAppName
1528} ) ;
1629
1730export const Settings = ( ) => {
1831 const [ displayOnPause , setDisplayOnPause ] = React . useState ( settings . displayOnPause ) ;
1932 const [ displayArtistIcon , setDisplayArtistIcon ] = React . useState ( settings . displayArtistIcon ) ;
2033 const [ displayPlaylistButton , setDisplayPlaylistButton ] = React . useState ( settings . displayPlaylistButton )
21- const [ status , setStatus ] = React . useState ( settings . status ) ;
34+ const [ status , setStatus ] = React . useState ( settings . status as PresenceStatus ) ;
2235 const [ customStatusText , setCustomStatusText ] = React . useState ( settings . customStatusText ) ;
36+ const [ customStatusPosition , setCustomStatusPosition ] = React . useState (
37+ Number ( settings . customStatusPosition ) as CustomStatusPosition
38+ ) ;
2339
2440 return (
2541 < LunaSettings >
@@ -62,10 +78,11 @@ export const Settings = () => {
6278 < LunaSelectSetting
6379 title = "Status text"
6480 desc = "What text that you're 'Listening to' in your Discord status"
65- value = { status }
81+ value = { String ( status ) }
6682 onChange = { ( e ) => {
67- const newStatus = parseInt ( e . target . value ) ;
68- setStatus ( ( settings . status = newStatus ) ) ;
83+ const newStatus = Number ( e . target . value ) as PresenceStatus ;
84+ setStatus ( settings . status = newStatus ) ;
85+
6986 updateActivity ( )
7087 . then ( ( ) => ( errSignal ! . _ = undefined ) )
7188 . catch ( trace . err . withContext ( "Failed to set activity" ) ) ;
@@ -78,29 +95,44 @@ export const Settings = () => {
7895 </ LunaSelectSetting >
7996
8097 { status === 3 && (
81- < LunaTextSetting
82- title = "Custom status text"
83- desc = {
84- < >
85- Set your own message for Discord activity.
86- < br />
87- You can use the following tags:
88- < ul >
89- < li > { `{artist}` } </ li >
90- < li > { `{track}` } </ li >
91- < li > { `{album}` } </ li >
92- </ ul >
93- Example: < b > { "Listening to {track} by {artist}" } </ b >
94- </ >
95- }
96- value = { customStatusText }
97- onChange = { ( e ) => {
98- setCustomStatusText ( ( settings . customStatusText = e . target . value ) ) ;
99- updateActivity ( )
100- . then ( ( ) => ( errSignal ! . _ = undefined ) )
101- . catch ( trace . err . withContext ( "Failed to set activity" ) ) ;
102- } }
103- />
98+ < div >
99+ < LunaTextSetting
100+ title = "Custom status text"
101+ desc = {
102+ < >
103+ Set your own message for Discord activity.
104+ < br />
105+ You can use the following tags:
106+ < ul >
107+ < li > { `{artist}` } </ li >
108+ < li > { `{track}` } </ li >
109+ < li > { `{album}` } </ li >
110+ </ ul >
111+ Example: < b > { "Listening to {track} by {artist}" } </ b >
112+ </ >
113+ }
114+ value = { customStatusText }
115+ onChange = { ( e ) => {
116+ setCustomStatusText ( ( settings . customStatusText = e . target . value ) ) ;
117+ updateActivity ( )
118+ . then ( ( ) => ( errSignal ! . _ = undefined ) )
119+ . catch ( trace . err . withContext ( "Failed to set activity" ) ) ;
120+ } }
121+ />
122+ < LunaSelectSetting
123+ title = "Custom status position"
124+ desc = "Choose what the custom status replaces in the rich presence area"
125+ value = { String ( customStatusPosition ) }
126+ onChange = { ( e ) => {
127+ const pos = Number ( e . target . value ) as CustomStatusPosition ;
128+ setCustomStatusPosition ( settings . customStatusPosition = pos ) ;
129+ updateActivity ( ) . catch ( trace . err . withContext ( "Failed to set activity" ) ) ;
130+ } }
131+ >
132+ < LunaSelectItem value = "0" children = "TIDAL" />
133+ < LunaSelectItem value = "1" children = "Track Name" />
134+ </ LunaSelectSetting >
135+ </ div >
104136 ) }
105137 </ LunaSettings >
106138 ) ;
0 commit comments