fix: apply fix from eslint

This commit is contained in:
JellyBrick
2024-02-18 11:58:26 +09:00
parent 9f5651a8ba
commit 4657aeca45
12 changed files with 67 additions and 51 deletions

View File

@ -586,7 +586,7 @@ app.whenReady().then(async () => {
); );
try { try {
// Check if shortcut is registered and valid // Check if shortcut is registered and valid
const shortcutDetails = shell.readShortcutLink(shortcutPath); // Throw error if doesn't exist yet const shortcutDetails = shell.readShortcutLink(shortcutPath); // Throw error if it doesn't exist yet
if ( if (
shortcutDetails.target !== appLocation || shortcutDetails.target !== appLocation ||
shortcutDetails.appUserModelId !== appID shortcutDetails.appUserModelId !== appID

View File

@ -30,7 +30,7 @@ import {
import { fetchFromGenius } from '@/plugins/lyrics-genius/main'; import { fetchFromGenius } from '@/plugins/lyrics-genius/main';
import { isEnabled } from '@/config/plugins'; import { isEnabled } from '@/config/plugins';
import { cleanupName, getImage, SongInfo } from '@/providers/song-info'; import { cleanupName, getImage, MediaType, type SongInfo } from '@/providers/song-info';
import { getNetFetchAsFetch } from '@/plugins/utils/main'; import { getNetFetchAsFetch } from '@/plugins/utils/main';
import { cache } from '@/providers/decorators'; import { cache } from '@/providers/decorators';
@ -686,6 +686,7 @@ const getMetadata = (info: TrackInfo): CustomSongInfo => ({
?.url, ?.url,
views: info.basic_info.view_count!, views: info.basic_info.view_count!,
songDuration: info.basic_info.duration!, songDuration: info.basic_info.duration!,
mediaType: MediaType.Audio,
}); });
// This is used to bypass age restrictions // This is used to bypass age restrictions

View File

@ -1,5 +1,6 @@
import { JSX, splitProps } from 'solid-js'; import { JSX, splitProps } from 'solid-js';
import { css } from 'solid-styled-components'; import { css } from 'solid-styled-components';
import { cache } from '@/providers/decorators'; import { cache } from '@/providers/decorators';
const menuStyle = cache(() => css` const menuStyle = cache(() => css`

View File

@ -4,6 +4,7 @@ import { css } from 'solid-styled-components';
import { Transition } from 'solid-transition-group'; import { Transition } from 'solid-transition-group';
import { autoUpdate, flip, offset, OffsetOptions, size } from '@floating-ui/dom'; import { autoUpdate, flip, offset, OffsetOptions, size } from '@floating-ui/dom';
import { useFloating } from 'solid-floating-ui'; import { useFloating } from 'solid-floating-ui';
import { cache } from '@/providers/decorators'; import { cache } from '@/providers/decorators';
const panelStyle = cache(() => css` const panelStyle = cache(() => css`

View File

@ -9,9 +9,10 @@ import { PanelItem } from './PanelItem';
import { IconButton } from './IconButton'; import { IconButton } from './IconButton';
import { WindowController } from './WindowController'; import { WindowController } from './WindowController';
import { cache } from '@/providers/decorators';
import type { RendererContext } from '@/types/contexts'; import type { RendererContext } from '@/types/contexts';
import type { InAppMenuConfig } from '../constants'; import type { InAppMenuConfig } from '../constants';
import { cache } from '@/providers/decorators';
const titleStyle = cache(() => css` const titleStyle = cache(() => css`
-webkit-app-region: drag; -webkit-app-region: drag;

View File

@ -38,7 +38,7 @@ export const fetchFromGenius = async (metadata: SongInfo) => {
const songArtist = `${cleanupName(metadata.artist)}`; const songArtist = `${cleanupName(metadata.artist)}`;
let lyrics: string | null; let lyrics: string | null;
/* Uses Regex to test the title and artist first for said characters if romanization is enabled. Otherwise normal /* Uses Regex to test the title and artist first for said characters if romanization is enabled. Otherwise, normal
Genius Lyrics behavior is observed. Genius Lyrics behavior is observed.
*/ */
let hasAsianChars = false; let hasAsianChars = false;

View File

@ -74,7 +74,7 @@ export class Connection {
return conn; return conn;
} }
async disconnect() { disconnect() {
if (this._mode === 'disconnected') throw new Error('Already disconnected'); if (this._mode === 'disconnected') throw new Error('Already disconnected');
this._mode = 'disconnected'; this._mode = 'disconnected';

View File

@ -76,7 +76,7 @@ export const defaultConfig: ScrobblerPluginConfig = {
enabled: false, enabled: false,
token: undefined, token: undefined,
session_key: undefined, session_key: undefined,
api_root: 'http://ws.audioscrobbler.com/2.0/', api_root: 'https://ws.audioscrobbler.com/2.0/',
api_key: '04d76faaac8726e60988e14c105d421a', api_key: '04d76faaac8726e60988e14c105d421a',
secret: 'a5d2a36fdf64819290f6982481eaffa2', secret: 'a5d2a36fdf64819290f6982481eaffa2',
}, },

View File

@ -1,4 +1,4 @@
import registerCallback, { type SongInfo } from '@/providers/song-info'; import registerCallback, { MediaType, type SongInfo } from '@/providers/song-info';
import { createBackend } from '@/utils'; import { createBackend } from '@/utils';
import { ScrobblerPluginConfig } from './index'; import { ScrobblerPluginConfig } from './index';
@ -52,7 +52,7 @@ export const backend = createBackend<{
if (!songInfo.isPaused) { if (!songInfo.isPaused) {
const configNonnull = this.config!; const configNonnull = this.config!;
// Scrobblers normally have no trouble working with official music videos // Scrobblers normally have no trouble working with official music videos
if (!configNonnull.scrobble_other_media && (songInfo.mediaType !== 'AUDIO' && songInfo.mediaType !== 'ORIGINAL_MUSIC_VIDEO')) { if (!configNonnull.scrobble_other_media && (songInfo.mediaType !== MediaType.Audio && songInfo.mediaType !== MediaType.OriginalMusicVideo)) {
return; return;
} }

View File

@ -1,18 +1,37 @@
import { t } from '@/i18n'; import { t } from '@/i18n';
import { createPlugin } from '@/utils'; import { createPlugin } from '@/utils';
export default createPlugin({ export default createPlugin<
unknown,
unknown,
{
observer?: MutationObserver;
waitForElem(selector: string): Promise<HTMLElement>;
start(): void;
stop(): void;
}
>({
name: () => t('plugins.skip-disliked-songs.name'), name: () => t('plugins.skip-disliked-songs.name'),
description: () => t('plugins.skip-disliked-songs.description'), description: () => t('plugins.skip-disliked-songs.description'),
restartNeeded: false, restartNeeded: false,
renderer: { renderer: {
observer: null as MutationObserver | null, waitForElem(selector: string) {
return new Promise<HTMLElement>((resolve) => {
const interval = setInterval(() => {
const elem = document.querySelector<HTMLElement>(selector);
if (!elem) return;
clearInterval(interval);
resolve(elem);
});
});
},
start() { start() {
this.waitForElem('#like-button-renderer').then((likeBtn) => { this.waitForElem('#like-button-renderer').then((likeBtn) => {
this.observer = new MutationObserver(() => { this.observer = new MutationObserver(() => {
if (likeBtn?.getAttribute('like-status') == 'DISLIKE') { if (likeBtn?.getAttribute('like-status') == 'DISLIKE') {
document document
.querySelector('tp-yt-paper-icon-button.next-button') .querySelector<HTMLButtonElement>('tp-yt-paper-icon-button.next-button')
?.click(); ?.click();
} }
}); });
@ -26,16 +45,5 @@ export default createPlugin({
stop() { stop() {
this.observer?.disconnect(); this.observer?.disconnect();
}, },
waitForElem(selector) {
return new Promise((resolve) => {
const interval = setInterval(() => {
const elem = document.querySelector(selector);
if (!elem) return;
clearInterval(interval);
resolve(elem);
});
});
},
}, },
}); });

View File

@ -3,33 +3,37 @@ import { BrowserWindow, ipcMain } from 'electron';
export default (win: BrowserWindow) => { export default (win: BrowserWindow) => {
const commands = { const commands = {
// Playback // Playback
previous: () => win.webContents.send('ytmd:previous-video'), previous: () => win.webContents.send('ytmd:previous-video'),
next: () => win.webContents.send('ytmd:next-video'), next: () => win.webContents.send('ytmd:next-video'),
playPause: () => win.webContents.send('ytmd:toggle-play'), playPause: () => win.webContents.send('ytmd:toggle-play'),
like: () => win.webContents.send('ytmd:update-like', 'LIKE'), like: () => win.webContents.send('ytmd:update-like', 'LIKE'),
dislike: () => win.webContents.send('ytmd:update-like', 'DISLIKE'), dislike: () => win.webContents.send('ytmd:update-like', 'DISLIKE'),
go10sBack: () => win.webContents.send('ytmd:seek-by', -10), go10sBack: () => win.webContents.send('ytmd:seek-by', -10),
go10sForward: () => win.webContents.send('ytmd:seek-by', 10), go10sForward: () => win.webContents.send('ytmd:seek-by', 10),
go1sBack: () => win.webContents.send('ytmd:seek-by', -1), go1sBack: () => win.webContents.send('ytmd:seek-by', -1),
go1sForward: () => win.webContents.send('ytmd:seek-by', 1), go1sForward: () => win.webContents.send('ytmd:seek-by', 1),
shuffle: () => win.webContents.send('ytmd:shuffle'), shuffle: () => win.webContents.send('ytmd:shuffle'),
switchRepeat: (n = 1) => win.webContents.send('ytmd:switch-repeat', n), switchRepeat: (n = 1) => win.webContents.send('ytmd:switch-repeat', n),
// General // General
volumeMinus10: () => { volumeMinus10: () => {
ipcMain.once('ytmd:get-volume-return', (_, volume) => { ipcMain.once('ytmd:get-volume-return', (_, volume) => {
win.webContents.send('ytmd:update-volume', volume - 10); win.webContents.send('ytmd:update-volume', volume - 10);
}); });
win.webContents.send('ytmd:get-volume'); win.webContents.send('ytmd:get-volume');
}, },
volumePlus10: () => { volumePlus10: () => {
ipcMain.once('ytmd:get-volume-return', (_, volume) => { ipcMain.once('ytmd:get-volume-return', (_, volume) => {
win.webContents.send('ytmd:update-volume', volume + 10); win.webContents.send('ytmd:update-volume', volume + 10);
}); });
win.webContents.send('ytmd:get-volume'); win.webContents.send('ytmd:get-volume');
}, },
fullscreen: () => win.webContents.send('ytmd:toggle-fullscreen'), fullscreen: () => win.webContents.send('ytmd:toggle-fullscreen'),
muteUnmute: () => win.webContents.send('ytmd:toggle-mute'), muteUnmute: () => win.webContents.send('ytmd:toggle-mute'),
search: () => win.webContents.sendInputEvent({
type: 'keyDown',
keyCode: '/',
}),
}; };
return { return {
...commands, ...commands,

View File

@ -7,7 +7,7 @@ import config from '@/config';
import type { GetPlayerResponse } from '@/types/get-player-response'; import type { GetPlayerResponse } from '@/types/get-player-response';
enum MediaType { export enum MediaType {
/** /**
* Audio uploaded by the original artist * Audio uploaded by the original artist
*/ */