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