mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix(discord): rename from 'timout' to 'timeout'
This commit is contained in:
@ -6,6 +6,21 @@ import defaults from './defaults';
|
||||
import { DefaultPresetList, type Preset } from '@/plugins/downloader/types';
|
||||
|
||||
const migrations = {
|
||||
'>=3.0.0'(store: Conf<Record<string, unknown>>) {
|
||||
const discordConfig = store.get('plugins.discord') as Record<string, unknown>;
|
||||
if (discordConfig) {
|
||||
const oldActivityTimoutEnabled = store.get('plugins.discord.activityTimoutEnabled') as boolean | undefined;
|
||||
const oldActivityTimoutTime = store.get('plugins.discord.activityTimoutTime') as number | undefined;
|
||||
if (oldActivityTimoutEnabled !== undefined) {
|
||||
discordConfig.activityTimeoutEnabled = oldActivityTimoutEnabled;
|
||||
store.set('plugins.discord', discordConfig);
|
||||
}
|
||||
if (oldActivityTimoutTime !== undefined) {
|
||||
discordConfig.activityTimeoutTime = oldActivityTimoutTime;
|
||||
store.set('plugins.discord', discordConfig);
|
||||
}
|
||||
}
|
||||
},
|
||||
'>=2.1.3'(store: Conf<Record<string, unknown>>) {
|
||||
const listenAlong = store.get('plugins.discord.listenAlong');
|
||||
if (listenAlong !== undefined) {
|
||||
|
||||
@ -13,13 +13,13 @@ export type DiscordPluginConfig = {
|
||||
/**
|
||||
* If enabled, the discord rich presence gets cleared when music paused after the time specified below
|
||||
*/
|
||||
activityTimoutEnabled: boolean;
|
||||
activityTimeoutEnabled: boolean;
|
||||
/**
|
||||
* The time in milliseconds after which the discord rich presence gets cleared when music paused
|
||||
*
|
||||
* @default 10 * 60 * 1000 (10 minutes)
|
||||
*/
|
||||
activityTimoutTime: number;
|
||||
activityTimeoutTime: number;
|
||||
/**
|
||||
* Add a "Play on YouTube Music" button to rich presence
|
||||
*/
|
||||
@ -40,8 +40,8 @@ export default createPlugin({
|
||||
config: {
|
||||
enabled: false,
|
||||
autoReconnect: true,
|
||||
activityTimoutEnabled: true,
|
||||
activityTimoutTime: 10 * 60 * 1000,
|
||||
activityTimeoutEnabled: true,
|
||||
activityTimeoutTime: 10 * 60 * 1000,
|
||||
playOnYouTubeMusic: true,
|
||||
hideGitHubButton: false,
|
||||
hideDurationLeft: false,
|
||||
|
||||
@ -122,7 +122,7 @@ export const backend = createBackend<{
|
||||
|
||||
info.lastSongInfo = songInfo;
|
||||
|
||||
// Stop the clear activity timout
|
||||
// Stop the clear activity timeout
|
||||
clearTimeout(clearActivity);
|
||||
|
||||
// Stop early if discord connection is not ready
|
||||
@ -132,7 +132,7 @@ export const backend = createBackend<{
|
||||
}
|
||||
|
||||
// Clear directly if timeout is 0
|
||||
if (songInfo.isPaused && config.activityTimoutEnabled && config.activityTimoutTime === 0) {
|
||||
if (songInfo.isPaused && config.activityTimeoutEnabled && config.activityTimeoutTime === 0) {
|
||||
info.rpc.user?.clearActivity().catch(console.error);
|
||||
return;
|
||||
}
|
||||
@ -167,8 +167,8 @@ export const backend = createBackend<{
|
||||
activityInfo.smallImageKey = 'paused';
|
||||
activityInfo.smallImageText = 'Paused';
|
||||
// Set start the timer so the activity gets cleared after a while if enabled
|
||||
if (config.activityTimoutEnabled) {
|
||||
clearActivity = setTimeout(() => info.rpc.user?.clearActivity().catch(console.error), config.activityTimoutTime ?? 10_000);
|
||||
if (config.activityTimeoutEnabled) {
|
||||
clearActivity = setTimeout(() => info.rpc.user?.clearActivity().catch(console.error), config.activityTimeoutTime ?? 10_000);
|
||||
}
|
||||
} else if (!config.hideDurationLeft) {
|
||||
// Add the start and end time of the song
|
||||
|
||||
@ -42,10 +42,10 @@ export const onMenu = async ({ window, getConfig, setConfig, refresh }: MenuCont
|
||||
{
|
||||
label: 'Clear activity after timeout',
|
||||
type: 'checkbox',
|
||||
checked: config.activityTimoutEnabled,
|
||||
checked: config.activityTimeoutEnabled,
|
||||
click(item: Electron.MenuItem) {
|
||||
setConfig({
|
||||
activityTimoutEnabled: item.checked,
|
||||
activityTimeoutEnabled: item.checked,
|
||||
});
|
||||
},
|
||||
},
|
||||
@ -90,7 +90,7 @@ async function setInactivityTimeout(win: Electron.BrowserWindow, options: Discor
|
||||
const output = await prompt({
|
||||
title: 'Set Inactivity Timeout',
|
||||
label: 'Enter inactivity timeout in seconds:',
|
||||
value: String(Math.round((options.activityTimoutTime ?? 0) / 1e3)),
|
||||
value: String(Math.round((options.activityTimeoutTime ?? 0) / 1e3)),
|
||||
type: 'counter',
|
||||
counterOptions: { minimum: 0, multiFire: true },
|
||||
width: 450,
|
||||
@ -98,7 +98,7 @@ async function setInactivityTimeout(win: Electron.BrowserWindow, options: Discor
|
||||
}, win);
|
||||
|
||||
if (output) {
|
||||
options.activityTimoutTime = Math.round(~~output * 1e3);
|
||||
options.activityTimeoutTime = Math.round(~~output * 1e3);
|
||||
setMenuOptions('discord', options);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user