Fix RPC customization settings

- Added logic to disable timestamp if not "listening to". - Added a
warning message if timestamp is unavailable.
This commit is contained in:
kmmiio99o 2025-11-16 17:10:12 +01:00
parent fdf24a1aeb
commit e3bbf71888

View file

@ -6,6 +6,7 @@ import {
Stack,
TableRowGroup,
TableSwitchRow,
TableRow,
} from "./components/TableComponents";
import { plugin } from "@vendetta";
import Constants from "../../../constants";
@ -16,6 +17,35 @@ export default function RPCCustomizationSettingsPage() {
useProxy(plugin.storage);
const [, forceUpdate] = React.useReducer((x) => x + 1, 0);
const isListeningTo = getStorage(
"listeningTo",
Constants.DEFAULT_SETTINGS.listeningTo,
);
const showTimestamp = getStorage(
"showTimestamp",
Constants.DEFAULT_SETTINGS.showTimestamp,
);
const handleListeningToChange = (value: boolean) => {
setStorage("listeningTo", value);
// If turning off "Show as Listening", also turn off "Show Timestamp"
if (!value && showTimestamp) {
setStorage("showTimestamp", false);
}
forceUpdate();
};
const handleTimestampChange = (value: boolean) => {
// Only allow turning on timestamp if "Show as Listening" is enabled
if (value && !isListeningTo) {
return;
}
setStorage("showTimestamp", value);
forceUpdate();
};
return (
<ScrollView style={{ flex: 1 }} contentContainerStyle={{ padding: 10 }}>
<RPCPreview />
@ -24,14 +54,8 @@ export default function RPCCustomizationSettingsPage() {
<TableSwitchRow
label="Show as Listening"
subLabel="Display as 'Listening to' instead of 'Playing'"
value={getStorage(
"listeningTo",
Constants.DEFAULT_SETTINGS.listeningTo,
)}
onValueChange={(value: boolean) => {
setStorage("listeningTo", value);
forceUpdate();
}}
value={isListeningTo}
onValueChange={handleListeningToChange}
/>
<TableSwitchRow
label="Show Tooltip Text"
@ -42,18 +66,26 @@ export default function RPCCustomizationSettingsPage() {
forceUpdate();
}}
/>
{/* Warning row when timestamp is disabled */}
{!isListeningTo && (
<TableRow
label="Timestamp Unavailable"
subLabel="Enable 'Show as Listening' to use timestamp feature"
disabled={true}
dimmed={true}
/>
)}
<TableSwitchRow
label="Show Timestamp"
subLabel="Display track progress and duration"
value={getStorage(
"showTimestamp",
Constants.DEFAULT_SETTINGS.showTimestamp,
)}
onValueChange={(value: boolean) => {
setStorage("showTimestamp", value);
forceUpdate();
}}
value={showTimestamp}
onValueChange={handleTimestampChange}
disabled={!isListeningTo}
dimmed={!isListeningTo}
/>
<TableSwitchRow
label="Show Album in Tooltip"
subLabel="Include album name in the tooltip text"