Compare commits

...

17 Commits

Author SHA1 Message Date
jeffvli 34314bdf46 update to v1.12.1 2026-05-28 02:06:41 -07:00
jeffvli 9d53c53c54 fix queue end handling to prevent repeat 2026-05-28 02:06:07 -07:00
jeffvli 8acd585630 clean up discord rpc implementation with usePlayerEvents 2026-05-28 01:50:29 -07:00
jeffvli 1f5907716f disable interval-based timeupdate scrobbles 2026-05-28 00:59:30 -07:00
jeffvli 99ae0c99c6 fix restart requirement logic when switching windowbar style 2026-05-28 00:46:07 -07:00
jeffvli a56253cd3a fix queue height when using web windowbar style (#2068) 2026-05-28 00:46:06 -07:00
Kendall Garner a2cdce66bc chore(github): update bug report template 2026-05-27 21:20:08 -07:00
Jonathan Grotelüschen 7454832663 fix: set RESOURCES_PATH relative to app.getAppPath() (#2064)
When running the app with system electron, process.resourcesPath points
to the resources folder of the system electron, not the one from
feishin.
2026-05-27 20:01:54 -07:00
Hosted Weblate 1ed185606d Translated using Weblate
Currently translated at 100.0% (1244 of 1244 strings) (Chinese (Traditional Han script))
Translation: feishin/Translation
Translate-URL: https://hosted.weblate.org/projects/feishin/translation/zh_Hant/

Translated using Weblate

Currently translated at 100.0% (1244 of 1244 strings) (Polish)
Translation: feishin/Translation
Translate-URL: https://hosted.weblate.org/projects/feishin/translation/pl/

Translated using Weblate

Currently translated at 54.9% (684 of 1244 strings) (German)
Translation: feishin/Translation
Translate-URL: https://hosted.weblate.org/projects/feishin/translation/de/

Translated using Weblate

Currently translated at 100.0% (1244 of 1244 strings) (Spanish)
Translation: feishin/Translation
Translate-URL: https://hosted.weblate.org/projects/feishin/translation/es/

Translated using Weblate

Currently translated at 100.0% (1244 of 1244 strings) (Czech)
Translation: feishin/Translation
Translate-URL: https://hosted.weblate.org/projects/feishin/translation/cs/

Translated using Weblate

Currently translated at 17.8% (222 of 1244 strings) (Arabic)
Translation: feishin/Translation
Translate-URL: https://hosted.weblate.org/projects/feishin/translation/ar/

Co-authored-by: Fjuro <fjuro@users.noreply.hosted.weblate.org>
Co-authored-by: Fordas <fordas15@gmail.com>
Co-authored-by: Laalo <hyohnoo3@gmail.com>
Co-authored-by: Zarakkas <kaz@users.noreply.hosted.weblate.org>
Co-authored-by: linger <linger0517@gmail.com>
Co-authored-by: skajmer <skajmer@protonmail.com>
2026-05-27 05:11:44 +00:00
jeffvli d9da588c7c add workaround for identical Jellyfin release name bug (#2041) 2026-05-26 22:06:40 -07:00
jeffvli e206136156 add physical key mapping for useHotkeys to support alt keyboard languages (#2051) 2026-05-26 21:55:08 -07:00
jeffvli 57b11e0dae remove invalid expand button on Playlist table index column 2026-05-26 20:49:19 -07:00
jeffvli 2fc130d709 validate mpv extra parameters to prevent empty string param (#2058) 2026-05-26 20:46:17 -07:00
jeffvli 1aa6b88cfa allow transcode on waveform streamURL (#2060) 2026-05-26 20:35:23 -07:00
jeffvli 329d028edd add open delay to scrobble status HoverCard 2026-05-26 20:05:01 -07:00
jeffvli 4955f30081 fix regression on numeric column designation (#2065) 2026-05-26 19:51:42 -07:00
jeffvli bf7ca937ff force pnpm v10 in dockerfile 2026-05-25 22:00:31 -07:00
30 changed files with 677 additions and 423 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ body:
- type: checkboxes
id: check-duplicate
attributes:
label: I have already checked through the existing bug reports and found no duplicates
label: I have already checked through the existing (both open AND closed) bug reports and found no duplicates
options:
- label: 'Yes'
required: true
+9 -5
View File
@@ -4,6 +4,11 @@ permissions: write-all
on:
workflow_dispatch:
inputs:
tag:
description: 'Docker image tag (e.g. 1.12.0 or latest)'
required: true
type: string
push:
tags:
- 'v*.*.*'
@@ -33,11 +38,10 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=semver,pattern={{version}},enable=${{ github.event_name == 'push' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'push' }}
type=semver,pattern={{major}},enable=${{ github.event_name == 'push' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
+2 -1
View File
@@ -5,7 +5,8 @@ WORKDIR /app
# Copy package.json first to cache node_modules
COPY package.json pnpm-lock.yaml .
RUN npm install -g pnpm
# Match CI (pnpm/action-setup version: 10). Latest pnpm 11 fails install without approve-builds.
RUN corepack enable && corepack prepare pnpm@10 --activate
RUN pnpm install
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "feishin",
"version": "1.12.0",
"version": "1.12.1",
"description": "A modern self-hosted music player.",
"keywords": [
"subsonic",
@@ -189,6 +189,7 @@
"pnpm": {
"onlyBuiltDependencies": [
"electron",
"electron-winstaller",
"esbuild"
]
},
+45 -8
View File
@@ -331,7 +331,10 @@
"serverRequired": "يتطلب خادم",
"sessionExpiredError": "انتهت صلاحية جلستك",
"systemFontError": "حدث خطأ أثناء محاولة الحصول على خطوط النظام",
"settingsSyncError": "تم اكتشاف تعارضات بين إعدادات العارض والعملية الرئيسية. أعد تشغيل التطبيق لتطبيق التغييرات"
"settingsSyncError": "تم اكتشاف تعارضات بين إعدادات العارض والعملية الرئيسية. أعد تشغيل التطبيق لتطبيق التغييرات",
"invalidJson": "JSON غير صالح",
"invalidServer": "خادم غير صالح",
"localFontAccessDenied": "تم رفض الوصول إلى الخطوط المحلية"
},
"filter": {
"album": "$t(entity.album, {\"count\": 1})",
@@ -372,7 +375,8 @@
"sortName": "أسم الفرز",
"title": "العنوان",
"toYear": "إلى سنة",
"trackNumber": "مقطع"
"trackNumber": "مقطع",
"isCompilation": "تجميعة"
},
"datetime": {
"minuteShort": "د",
@@ -413,14 +417,19 @@
"input_url": "الرابط",
"input_username": "أسم المستخدم",
"success": "تمت إضافة الخادم بنجاح",
"title": "إضافة خادم"
"title": "إضافة خادم",
"input_preferInstantMix": "تفضيل الميكس الفوري",
"input_preferInstantMixDescription": "استخدم الميكس الفوري فقط للحصول على أغاني مشابهة. مفيد إذا كان لديك إضافات تعدّل هذا السلوك",
"input_remoteUrlPlaceholder": "اختياري: عنوان URL عام للميزات الخارجية"
},
"largeFetchConfirmation": {
"title": "أضف العناصر إلى قائمة التشغيل"
"title": "أضف العناصر إلى قائمة التشغيل",
"description": "سيقوم هذا الإجراء بإضافة جميع العناصر في العرض المفلتر الحالي"
},
"addToPlaylist": {
"input_skipDuplicates": "تخطي العناصر المكررة",
"title": "أضف إلى $t(entity.playlist, {\"count\": 1})"
"title": "أضف إلى $t(entity.playlist, {\"count\": 1})",
"create": "إنشاء $t(entity.playlist, {\"count\": 1}) {{playlist}}"
},
"createPlaylist": {
"input_public": "عام"
@@ -428,7 +437,9 @@
"createRadioStation": {
"input_homepageUrl": "رابط الرئيسية",
"input_name": "الأسم",
"input_streamUrl": "رابط البث"
"input_streamUrl": "رابط البث",
"success": "تم إنشاء محطة راديو جديدة بنجاح",
"title": "إنشاء محطة راديو"
},
"editRadioStation": {
"success": "تم تحديث محطة الراديو بنجاح"
@@ -440,7 +451,8 @@
},
"editPlaylist": {
"success": "تم تحديث $t(entity.playlist, {\"count\": 1}) بنجاح",
"title": "تعديل $t(entity.playlist, {\"count\": 1})"
"title": "تعديل $t(entity.playlist, {\"count\": 1})",
"publicJellyfinNote": "لسبب ما، لا يكشف Jellyfin عما إذا كانت قائمة التشغيل عامة أم لا. إذا كنت ترغب في إبقائها عامة، يرجى التأكد من تحديد الخيار التالي"
},
"lyricsExport": {
"export": "تصدير الكلمات",
@@ -451,7 +463,32 @@
},
"queryEditor": {
"input_optionMatchAll": "تطابق الجميع",
"input_optionMatchAny": "تطابق أي"
"input_optionMatchAny": "تطابق أي",
"title": "محرر الاستعلامات",
"addRuleGroup": "إضافة مجموعة قواعد",
"removeRuleGroup": "إزالة مجموعة قواعد",
"resetToDefault": "استعادة الإعدادات الافتراضية"
},
"shareItem": {
"allowDownloading": "السماح بالتحميل",
"description": "الوصف"
},
"shuffleAll": {
"title": "تشغيل عشوائي",
"input_kind_albums": "ألبومات",
"input_kind_songs": "أغاني",
"input_kind": "إختيارات عشوائية",
"input_minYear": "من سنة",
"input_maxYear": "إلى سنة"
},
"updateServer": {
"success": "تم تحديث الخادم بنجاح",
"title": "تحديث الخادم"
}
},
"page": {
"albumArtistDetail": {
"favoriteSongs": "الأغاني المفضلة"
}
}
}
+20 -5
View File
@@ -234,7 +234,7 @@
"customCssEnable": "Povolit vlastní CSS",
"customCssEnable_description": "Umožnit psaní vlastního CSS",
"customCssNotice": "Varování: i když provádíme určitou sanitizaci (zakázáním URL() a content:), může používání CSS stále představovat riziko změnami rozhraní",
"customCss_description": "Vlastní CSS obsah. Upozornění: vlastnosti content a vzdálené URL jsou zakázané. Níže je zobrazen náhled vašeho obsahu. Další pole, která jste nenastavili, jsou přítomna z důvodu sanitizace",
"customCss_description": "Vlastní CSS obsah. Upozornění: vlastnosti content a vzdálené URL jsou zakázané. Níže je zobrazen náhled vašeho obsahu. Další pole, která jste nenastavili, jsou přítomna z důvodu sanitizace. Počítačový Feishin čte a zapisuje soubor custom.css do konfiguračního adresáře aplikace a znovu jej načte po jeho změně",
"customCss": "Vlastní css",
"webAudio": "Použít webový zvuk",
"webAudio_description": "Použít webový zvuk. Tím povolíte pokročilé funkce jako ReplayGain. Zakažte, pokud se objeví problémy",
@@ -345,7 +345,7 @@
"playerbarSlider_description": "Vlnová křivka není doporučena, pokud se nacházíte na pomalém nebo měřeném internetovém připojení",
"autoDJ": "Automatický DJ",
"autoDJ_itemCount": "Počet položek",
"autoDJ_itemCount_description": "Počet položek, které se pokusíme přidat do fronty po povolení automatického DJ",
"autoDJ_itemCount_description": "Počet položek, které se pokusíme přidat do fronty",
"autoDJ_timing": "Časování",
"autoDJ_timing_description": "Počet skladeb zbývajících ve frontě před spuštěním automatického DJ",
"logLevel": "Úroveň protokolu",
@@ -447,7 +447,16 @@
"sidebarPlaylistMode_description": "Jak je každý seznam skladeb zobrazen v seznamu v postranní liště",
"sidebarPlaylistMode": "Režim seznamů skladeb v postranní liště",
"sidebarPlaylistMode_optionCompact": "Kompaktní",
"sidebarPlaylistMode_optionExpanded": "Rozšířený"
"sidebarPlaylistMode_optionExpanded": "Rozšířený",
"autoDJ_mode": "Režim",
"autoDJ_mode_albums": "Alba",
"autoDJ_mode_description": "Vyberte, zda do fronty přidávat skladby nebo celá alba",
"autoDJ_mode_songs": "Skladby",
"autoDJ_enabled": "Povolit automatického DJ",
"autoDJ_albumStrategy": "Režim výběru alb",
"autoDJ_songStrategy": "Režim výběru skladeb",
"autoDJ_strategy_option_library_random": "Náhodně",
"autoDJ_strategy_option_similar": "Podobné"
},
"action": {
"editPlaylist": "Upravit $t(entity.playlist, {\"count\": 1})",
@@ -623,7 +632,8 @@
"newVersionAvailable": "Je dostupná nová verze",
"numberOfResults": "{{numberOfResults}} výsledků",
"grouping": "Seskupování",
"back": "Zpět"
"back": "Zpět",
"openFolder": "Otevřít složku"
},
"table": {
"config": {
@@ -1122,7 +1132,12 @@
"input_played": "Přehrát filtr",
"input_played_optionAll": "Všechny skladby",
"input_played_optionUnplayed": "Pouze nepřehrané skladby",
"input_played_optionPlayed": "Pouze přehrané skladby"
"input_played_optionPlayed": "Pouze přehrané skladby",
"input_kind_albums": "Alba",
"input_kind_songs": "Skladby",
"input_kind": "Náhodný výběr",
"input_limit_albums": "Kolik alb?",
"input_limit_songs": "Kolik skladeb?"
},
"saveQueue": {
"success": "Fronta přehrávání uložena na server"
+42 -33
View File
@@ -13,7 +13,7 @@
"removeFromPlaylist": "Aus $t(entity.playlist, {\"count\": 1}) entfernen",
"viewPlaylists": "$t(entity.playlist, {\"count\": 2}) anzeigen",
"refresh": "$t(common.refresh)",
"removeFromQueue": "Aus wiedergabeliste entfernen",
"removeFromQueue": "Aus Wiedergabeliste entfernen",
"setRating": "Bewertung setzen",
"toggleSmartPlaylistEditor": "Editor für $t(entity.smartPlaylist) ein-/ausblenden",
"removeFromFavorites": "Aus $t(entity.favorite, {\"count\": 2}) entfernen",
@@ -169,7 +169,8 @@
"filter_multiple": "Mehrfach",
"retry": "Erneut versuchen",
"newVersionAvailable": "Eine neue version ist verfügbar",
"numberOfResults": "{{numberOfResults}} ergebnisse"
"numberOfResults": "{{numberOfResults}} ergebnisse",
"openFolder": "Verzeichnis öffnen"
},
"error": {
"remotePortWarning": "Starten Sie den Server neu, um den neuen Port anzuwenden",
@@ -191,13 +192,13 @@
"audioDeviceFetchError": "Beim Versuch, Audiogeräte abzurufen, ist ein Fehler aufgetreten",
"invalidServer": "Ungültiger Server",
"loginRateError": "Zu viele Anmeldeversuche, bitte versuche es in einigen Sekunden erneut",
"badAlbum": "Sie sehen diese Seite, weil dieses Lied nicht Teil eines Albums ist. Dieses Problem tritt meist auf, wenn sich ein Lied im Überordner befindet. Jellyfin gruppiert Tracks nur, wenn diese sich innerhalb eines Ordners befinden",
"badAlbum": "Sie sehen diese Seite, weil dieses Lied nicht Teil eines Albums ist. Dieses Problem tritt meist auf, wenn sich ein Lied im Überordner befindet. Jellyfin gruppiert Tracks nur, wenn diese sich innerhalb eines Verzeichnisses befinden",
"networkError": "Ein Netzwerkfehler ist aufgetreten",
"openError": "Datei kann nicht geöffnet werden",
"badValue": "Ungültige option \"{{value}}\". Dieser Wert existiert nicht mehr",
"notificationDenied": "Berechtigungen über Benachrichtigungen wurden verweigert. Diese Einstellung hat keinen Effekt",
"saveQueueFailed": "Wiedergabeliste konnte nicht gespeichert werden",
"multipleServerSaveQueueError": "Die Wiedergabeliste enthält einen oder mehrere Titel, die nicht vom aktuellen Server stammen. dies wird nicht unterstützt",
"multipleServerSaveQueueError": "Die Wiedergabeliste enthält einen oder mehrere Titel, die nicht vom aktuellen Server stammen. Dies wird nicht unterstützt",
"noNetwork": "Server nicht verfügbar",
"noNetworkDescription": "Verbindung zum Server konnte nicht hergestellt werden",
"invalidJson": "JSON ungültig",
@@ -309,7 +310,7 @@
"editPlaylist": {
"title": "Bearbeite $t(entity.playlist, {\"count\": 1})",
"success": "$t(entity.playlist, {\"count\": 1}) erfolgreich aktualisiert",
"publicJellyfinNote": "Jellyfin legt aus irgendwelchen Gründen nicht offen ob eine Wiedergabeliste öffentlich ist oder nicht. Wenn du möchtest, dass sie öffentlich bleibt, wähle bitte diese Option aus"
"publicJellyfinNote": "Jellyfin legt aus irgendwelchen Gründen nicht offen, ob eine Wiedergabeliste öffentlich ist oder nicht. Wenn du möchtest, dass sie öffentlich bleibt, wähle bitte diese Option aus"
},
"lyricSearch": {
"title": "Songtext suche",
@@ -332,7 +333,7 @@
"title": "Privater Modus"
},
"largeFetchConfirmation": {
"title": "Elemente der wiedergabeliste hinzufügen",
"title": "Elemente der Wiedergabeliste hinzufügen",
"description": "Diese Aktion fügt alle Elemente in der aktuell gefilterten Ansicht hinzu"
},
"shuffleAll": {
@@ -347,7 +348,7 @@
"input_played": "Wiedergabefilter"
},
"saveQueue": {
"success": "Wiedergabeliste auf server gespeichert"
"success": "Wiedergabeliste auf Server gespeichert"
},
"createRadioStation": {
"success": "Radiosender erfolgreich erstellt",
@@ -368,14 +369,14 @@
"entity": {
"genre_one": "Genre",
"genre_other": "Genres",
"playlistWithCount_one": "{{count}} wiedergabeliste",
"playlistWithCount_other": "{{count}} wiedergabelisten",
"playlistWithCount_one": "{{count}} Wiedergabeliste",
"playlistWithCount_other": "{{count}} Wiedergabelisten",
"playlist_one": "Wiedergabeliste",
"playlist_other": "Wiedergabelisten",
"artist_one": "Interpret",
"artist_other": "Interpreten",
"folderWithCount_one": "{{count}} verzeichnis",
"folderWithCount_other": "{{count}} verzeichnisse",
"folderWithCount_one": "{{count}} Verzeichnis",
"folderWithCount_other": "{{count}} Verzeichnisse",
"albumArtist_one": "Albuminterpret",
"albumArtist_other": "Albuminterpreten",
"track_one": "Track",
@@ -552,9 +553,9 @@
"privateModeOff": "Privaten Modus deaktivieren",
"privateModeOn": "Privaten Modus aktivieren",
"commandPalette": "Kommandopalette öffnen",
"selectMusicFolder": "Musikordner wählen",
"noMusicFolder": "Kein musikordner gewählt",
"multipleMusicFolders": "{{count}} musikordner ausgewählt"
"selectMusicFolder": "Musikverzeichnis wählen",
"noMusicFolder": "Kein Musikverzeichnis gewählt",
"multipleMusicFolders": "{{count}} Musikverzeichnis ausgewählt"
},
"home": {
"mostPlayed": "Meistgespielt",
@@ -681,7 +682,7 @@
"topSongs": "Toplieder",
"relatedArtists": "Ähnliche $t(entity.artist, {\"count\": 2})",
"groupingTypeAll": "Alle veröffentlichungsformate",
"groupingTypePrimary": "Primäre veröffentlichungsformate",
"groupingTypePrimary": "Primäre Veröffentlichungsformate",
"favoriteSongs": "Lieblingslieder",
"favoriteSongsFrom": "Liebslingslieder von {{title}}",
"topSongsCommunity": "Community",
@@ -761,8 +762,8 @@
"addLastShuffled": "Als Letztes (zufällige Wiedergabe)",
"addNextShuffled": "Als Nächstes (zufällige Wiedergabe)",
"holdToShuffle": "Halten für zufallswiedergabe",
"restoreQueueFromServer": "Wiedergabeliste von server wiederherstellen",
"saveQueueToServer": "Wiedergabeliste auf server speichern",
"restoreQueueFromServer": "Wiedergabeliste von Server wiederherstellen",
"saveQueueToServer": "Wiedergabeliste auf Server speichern",
"lyrics": "Songtexte",
"artistRadio": "Künstler radio",
"sleepTimer_endOfSong": "Ende des aktuellen liedes",
@@ -900,13 +901,13 @@
"sidebarPlaylistSorting": "Wiedergabelisten-sortierung in der seitenleiste",
"minimizeToTray": "Zur taskleiste minimieren",
"skipPlaylistPage": "Wiedergabeliste-seite überspringen",
"themeDark": "Erscheinungsbild (dunkel)",
"themeDark": "Design (dunkel)",
"sidebarCollapsedNavigation": "Navigation in der seitenleiste (komprimiert)",
"gaplessAudio_optionWeak": "Schwach (empfohlen)",
"minimumScrobbleSeconds": "Minimum scrobble-dauer (sekunden)",
"hotkey_playbackStop": "Stoppen",
"savePlayQueue_description": "Speichert die Wiedergabeliste beim Schließen der Anwendung, und stellt diese wieder her, wenn die Anwendung geöffnet wird",
"useSystemTheme": "Nach erscheinungsbild des systems richten",
"useSystemTheme": "Nach Erscheinungsbild des Systems richten",
"enableRemote_description": "Aktiviert den Server für die Fernsteuerung, damit andere Geräte die Anwendung steuern können",
"fontType_optionSystem": "System schriftart",
"discordUpdateInterval": "{{discord}} rich presence aktualisierungsintervall",
@@ -922,7 +923,7 @@
"fontType": "Schriftartenquelle",
"followLyric": "Aktuellen songtext synchronisieren",
"font_description": "Wähle die Schriftart für die Anwendung",
"themeLight": "Erscheinungsbild (hell)",
"themeLight": "Design (hell)",
"sidePlayQueueStyle_optionDetached": "Lösgelöst",
"windowBarStyle_description": "Legt das Erscheinungsbild des Fensterrahmens fest",
"hotkey_toggleCurrentSongFavorite": "$t(common.currentSong) zu favoriten hinzufügen",
@@ -950,7 +951,7 @@
"albumBackgroundBlur_description": "Passt die Stärke der Unschärfe an, welche auf das Hintergrundbild des Albums angewandt wird",
"clearCacheSuccess": "Cache erfolgreich geleert",
"contextMenu": "Kontextmenü-einstellungen (rechtsklick)",
"customCssEnable_description": "Erlaubt das hinzufügen von benutzerdefiniertem CSS",
"customCssEnable_description": "Erlaubt das Hinzufügen von benutzerdefiniertem CSS",
"artistBackground": "Künstler hintergrundbild",
"artistBackground_description": "Fügt ein Hintergrundbild für die Künstlerseite hinzu",
"artistConfiguration": "Künstler albumseite konfiguration",
@@ -980,8 +981,8 @@
"logLevel_optionWarn": "Warnung",
"autoDJ": "Auto DJ",
"autoDJ_itemCount": "Anzahl",
"autoDJ_itemCount_description": "Die anzahl der lieder, die bei aktiviertem auto DJ zur wiedergabeliste hinzugefügt werden sollen",
"autoDJ_timing_description": "Die anzahl der lieder, die sich noch in der wiedergabeliste befinden, bevor auto DJ ausgelöst wird",
"autoDJ_itemCount_description": "Die Anzahl der Lieder, die zur Wiedergabeliste hinzugefügt werden soll",
"autoDJ_timing_description": "Die Anzahl der Lieder, die sich noch in der Wiedergabeliste befinden, bevor Auto-DJ ausgelöst wird",
"autoDJ_timing": "Timing",
"discordDisplayType": "{{discord}} presence darstellungsart",
"discordLinkType_mbz_lastfm": "{{musicbrainz}} mit {{lastfm}} als ersatz",
@@ -1022,7 +1023,7 @@
"artistConfiguration_description": "Legt fest, welche Elemente auf der Albumkünstlerseite angezeigt werden und in welcher Reihenfolge",
"contextMenu_description": "Legt die Einträge fest, die im Rechtsklick-Menü angezeigt werden sollen. Abgewählte Einträge werden ausgeblendet",
"crossfadeStyle": "Art der überblende",
"customCss_description": "Benutzerdefinierter CSS-inhalt. Hinweis: inhalte und remote-urls sind nicht zulässige eigenschaften. Unten siehst du eine vorschau deines inhalts. Aufgrund von bereinigung werden womöglich zusätzliche, nicht von dir definierte felder angezeigt",
"customCss_description": "Benutzerdefinierter CSS-Inhalt. Hinweis: Content und Remote URLs sind nicht zulässige Eigenschaften. Eine Vorschau deines Inhalts wird unten angezeigt. Aufgrund von Bereinigung werden womöglich zusätzliche, nicht von dir definierte Felder angezeigt. Desktop: Feishin liest und schreibt in eine custom.css Datei im App-Konfigurationsverzeichnis, und lädt diese neu, wenn sich die Datei ändert.",
"customCssNotice": "Warnung: obwohl eine gewisse bereinigung erfolgt (nicht zulässig sind z. B. \"URL()\" und \"content:\"), kann ein benutzerdefiniertes CSS risiken mit sich bringen, da die benutzeroberfläche dadurch verändert wird",
"releaseChannel_optionBeta": "Beta",
"releaseChannel_optionLatest": "Stabil",
@@ -1064,7 +1065,7 @@
"automaticUpdates": "Automatische updates",
"automaticUpdates_description": "Updates automatisch suchen und installieren",
"releaseChannel_optionAlpha": "Alpha (nightly)",
"useThemeAccentColor": "Akzentfarbe des themas nutzen",
"useThemeAccentColor": "Standard Akzentfarbe übernehmen",
"analyticsEnable_description": "Anonymisierte Nutzungsdaten werden an den Entwickler gesendet, um die Anwendung zu verbessern",
"artistReleaseTypeConfiguration_description": "Konfigurieren, welche Release-Typen und in welcher Reihenfolge diese auf der Album-Künstlerseite angezeigt werden",
"homeConfiguration_description": "Konfigurieren, welche Elemente und in welcher Reihenfolge diese auf der Startseite angezeigt werden",
@@ -1111,14 +1112,14 @@
"queryBuilder": "Abfrage-editor",
"queryBuilderCustomFields_inputLabel": "Label",
"queryBuilderCustomFields_description": "Füge benutzerdefinierte Felder für den Abfrage-Editor hinzu",
"autosave": "Automatisch aktuelle wiedergabeliste speichern",
"autosave_description": "Aktiviere die automatische speicherung der aktuellen wiedergabe auf dem server. Diese funktion ist nur bei Navidrome/Subsonic servern verfügbar und es darf sich nicht um eine gemischte wiedergabeliste handeln.",
"autosaveCount": "Häufigkeit der automatischen speicherung bei wiedergabelisten",
"autosave": "Automatisch aktuelle Wiedergabeliste speichern",
"autosave_description": "Aktiviere die automatische Speicherung der aktuellen Wiedergabe auf dem Server. Diese Funktion ist nur bei Navidrome/Subsonic Servern verfügbar und es darf sich nicht um eine gemischte Wiedergabeliste handeln.",
"autosaveCount": "Häufigkeit der automatischen Speicherung bei Wiedergabelisten",
"autosaveCount_description": "Wieviele Lieder gespielt werden, bevor die Wiedergabeliste gespeichert wird. 1 (Minimum) bedeutet die Speicherung nach jedem gespielten Lied",
"useThemeAccentColor_description": "Verwendet die Primärfarbe des gewählten Themas anstatt einer ausgewählten Akzentfarbe",
"useThemePrimaryShade": "Primärschatten des themas nutzen",
"useThemePrimaryShade_description": "Verwendet den Primärschatten des ausgewählten Themas als primäre Farbvarianten",
"primaryShade": "Primärschatten",
"useThemeAccentColor_description": "Verwendet die primäre Farbe des gewählten Designs",
"useThemePrimaryShade": "Standard Farbton übernehmen",
"useThemePrimaryShade_description": "Verwendet den primären Farbton des ausgewählten Designs für die Primärfarbvarianten",
"primaryShade": "Primärer Farbton",
"listenbrainz": "ListenBrainz Links anzeigen",
"listenbrainz_description": "Zeige Links zu ListenBrainz auf den Interpreten/Alben Seiten",
"mpvExtraParameters": "Zusätzliche mpv parameter",
@@ -1133,7 +1134,15 @@
"nativeSpotify_description": "In der Spotify app statt im browser öffnen",
"imageResolution_optionFullScreenPlayer": "Wiedergabe im vollbildmodus",
"sidePlayQueueLayout_optionHorizontal": "Horizontal",
"sidePlayQueueLayout_optionVertical": "Vertikal"
"sidePlayQueueLayout_optionVertical": "Vertikal",
"sidebarPlaylistFolders": "Verzeichnisse aktivieren",
"sidebarPlaylistFolderSeparator": "Verzeichnistrennzeichen",
"sidebarPlaylistFolderView_description": "Wie Verzeichnisse in der Seitenleiste angezeigt werden",
"sidebarPlaylistFolderView": "Verzeichnisansicht",
"sidebarPlaylistFolderView_optionSingle": "Einzelne Ordner",
"sidebarPlaylistFolderView_optionTree": "Baumstruktur",
"sidebarPlaylistFolderView_optionNavigation": "Navigationsansicht",
"sidebarPlaylistFolderSeparator_description": "Zeichen (oder Zeichenfolge), das die Verzeichnisebenen im Wiedergabelistentitel trennt"
},
"dragDropZone": {
"error_oneFileOnly": "Bitte wähle nur 1 Datei",
+20 -5
View File
@@ -235,7 +235,7 @@
"customCssEnable_description": "Permite escribir CSS personalizado",
"customCss": "CSS personalizado",
"customCssNotice": "Aviso: mientras hay alguna sanitización (rechazar URL() y content:), usar CSS personalizado puede aún entrañar riesgos cambiando la interfaz",
"customCss_description": "Content CSS personalizado. Nota: content y urls remotas son propiedades rechazadas. Una vista previa de tu content se muestra debajo. Las entradas adicionales que no estableciste están presentes debido a la sanitización",
"customCss_description": "Content CSS personalizado. Nota: content y remote urls son propiedades rechazadas. Una vista previa de tu content se muestra debajo. Las entradas adicionales que no estableciste están presentes debido a la sanitización. Escritorio: Feishin lee y escribe custom.css en el directorio de configuración de la aplicación y lo recarga cuando cambia el archivo",
"webAudio": "Usar audio web",
"webAudio_description": "Utilizar audio web. Esto habilita funciones avanzadas como ReplayGain. Desactiva esta opción si tienes problemas",
"transcode_description": "Permite la transcodificación a distintos formatos",
@@ -345,7 +345,7 @@
"playerbarSlider_description": "La forma de onda no es recomendable en una conexión a Internet lenta o medida",
"autoDJ": "DJ Automático",
"autoDJ_itemCount": "Recuento de elementos",
"autoDJ_itemCount_description": "El número de elementos que se ha intentado añadir a la cola cuando DJ automático está activado",
"autoDJ_itemCount_description": "El número de elementos que se ha intentado añadir a la cola",
"autoDJ_timing_description": "El número de canciones restantes en la cola antes de que DJ automático se dispare",
"autoDJ_timing": "Tiempo",
"logLevel": "Nivel de registro",
@@ -447,7 +447,16 @@
"sidebarPlaylistMode_optionCompact": "Compacto",
"sidebarPlaylistMode_optionExpanded": "Expandido",
"sidebarPlaylistMode_description": "Cómo se muestra cada lista de reproducción en la lista de la barra lateral",
"sidebarPlaylistFolderTreeIndent_description": "Píxeles que está sangrado cada nivel del árbol"
"sidebarPlaylistFolderTreeIndent_description": "Píxeles que está sangrado cada nivel del árbol",
"autoDJ_mode": "Modo",
"autoDJ_mode_albums": "Álbumes",
"autoDJ_mode_songs": "Canciones",
"autoDJ_enabled": "Activar DJ automático",
"autoDJ_albumStrategy": "Modo de selección de álbum",
"autoDJ_songStrategy": "Modo de selección de canción",
"autoDJ_strategy_option_library_random": "Aleatorio",
"autoDJ_strategy_option_similar": "Similar",
"autoDJ_mode_description": "Elegir para añadir canciones o álbumes enteros a la cola"
},
"action": {
"editPlaylist": "Editar $t(entity.playlist, {\"count\": 1})",
@@ -623,7 +632,8 @@
"newVersionAvailable": "Una nueva versión está disponible",
"numberOfResults": "{{numberOfResults}} resultados",
"grouping": "Agrupar",
"back": "Atrás"
"back": "Atrás",
"openFolder": "Abrir carpeta"
},
"error": {
"remotePortWarning": "Reiniciar el servidor para aplicar el nuevo puerto",
@@ -1013,7 +1023,12 @@
"input_played": "Reproducir filtro",
"input_played_optionAll": "Todas las pistas",
"input_played_optionUnplayed": "Solo las pistas sin reproducir",
"input_played_optionPlayed": "Solo las pistas reproducidas"
"input_played_optionPlayed": "Solo las pistas reproducidas",
"input_kind_albums": "Álbumes",
"input_kind_songs": "Canciones",
"input_limit_albums": "¿Cuántos álbumes?",
"input_limit_songs": "¿Cuántas canciones?",
"input_kind": "Selecciones aleatorias"
},
"saveQueue": {
"success": "Cola de reproducción guardada en el servidor"
+17 -3
View File
@@ -410,7 +410,12 @@
"input_played": "Filtr odtwarzania",
"input_played_optionAll": "Wszystkie utwory",
"input_played_optionUnplayed": "Tylko nieodtworzone utwory",
"input_played_optionPlayed": "Tylko odtworzone utwory"
"input_played_optionPlayed": "Tylko odtworzone utwory",
"input_kind_albums": "Albumy",
"input_kind_songs": "Piosenki",
"input_kind": "Losowy wybór",
"input_limit_albums": "Ile albumów?",
"input_limit_songs": "Ile piosenek?"
},
"saveQueue": {
"success": "Zapisano kolejkę odtwarzania na serwerze"
@@ -991,7 +996,7 @@
"audioFadeOnStatusChange_description": "Umożliwia zanikanie lub pojawianie się dźwięku gdy zmieni się status play/pauza",
"autoDJ": "Automatyczny DJ",
"autoDJ_itemCount": "Liczba elementów",
"autoDJ_itemCount_description": "Liczba elementów, które będzie próbować dodać do kolejki kiedy automatyczny DJ jest włączony",
"autoDJ_itemCount_description": "Liczba elementów, które będzie próbować dodać do kolejki",
"autoDJ_timing": "Czas dodawania",
"autoDJ_timing_description": "Ilość piosenek pozostałych w kolejce przed tym gdy zostanie włączony automatyczny DJ",
"logLevel": "Poziom logów",
@@ -1093,7 +1098,16 @@
"sidebarPlaylistMode_description": "Jak każda z playlist jest wyświetlana w liście w pasku bocznym",
"sidebarPlaylistMode": "Tryb playlist bocznego paska",
"sidebarPlaylistMode_optionCompact": "Kompaktowy",
"sidebarPlaylistMode_optionExpanded": "Rozszerzony"
"sidebarPlaylistMode_optionExpanded": "Rozszerzony",
"autoDJ_mode": "Tryb",
"autoDJ_mode_albums": "Albumy",
"autoDJ_mode_description": "Wybierz dodawanie piosenek lub całych albumów do kolejki",
"autoDJ_mode_songs": "Piosenki",
"autoDJ_enabled": "Włącz Auto DJ",
"autoDJ_albumStrategy": "Tryb wyboru albumów",
"autoDJ_songStrategy": "Tryb wyboru piosenek",
"autoDJ_strategy_option_library_random": "Losowo",
"autoDJ_strategy_option_similar": "Podobne"
},
"table": {
"config": {
+18 -4
View File
@@ -715,8 +715,8 @@
"playerFilters": "從佇列中過濾歌曲",
"playerFilters_description": "根據以下條件,排除要新增至佇列中的歌曲",
"autoDJ": "Auto DJ",
"autoDJ_itemCount": "歌曲數量",
"autoDJ_itemCount_description": "在啟用Auto DJ時嘗試加入佇列的歌曲數量",
"autoDJ_itemCount": "項目數量",
"autoDJ_itemCount_description": "嘗試加入佇列的項目數量",
"autoDJ_timing_description": "佇列中剩餘多少歌曲時啟動 Auto DJ",
"autoDJ_timing": "觸發時機",
"logLevel": "Log等級",
@@ -818,7 +818,16 @@
"sidebarPlaylistMode_description": "各播放清單在側邊欄列表中的顯示方式",
"sidebarPlaylistMode": "側邊欄播放清單模式",
"sidebarPlaylistMode_optionCompact": "緊湊",
"sidebarPlaylistMode_optionExpanded": "展開"
"sidebarPlaylistMode_optionExpanded": "展開",
"autoDJ_mode": "模式",
"autoDJ_mode_albums": "專輯",
"autoDJ_mode_description": "選擇將歌曲或整張專輯加入佇列",
"autoDJ_mode_songs": "歌曲",
"autoDJ_enabled": "啟用Auto DJ",
"autoDJ_albumStrategy": "專輯選擇模式",
"autoDJ_songStrategy": "歌曲選擇模式",
"autoDJ_strategy_option_library_random": "隨機",
"autoDJ_strategy_option_similar": "相似"
},
"table": {
"config": {
@@ -1137,7 +1146,12 @@
"input_played": "播放過濾器",
"input_played_optionAll": "所有曲目",
"input_played_optionUnplayed": "僅未播放的曲目",
"input_played_optionPlayed": "僅播放過的曲目"
"input_played_optionPlayed": "僅播放過的曲目",
"input_kind_albums": "專輯",
"input_kind_songs": "歌曲",
"input_kind": "隨機選取",
"input_limit_albums": "專輯數量?",
"input_limit_songs": "歌曲數量?"
},
"createRadioStation": {
"success": "電台建立成功",
+7 -1
View File
@@ -120,8 +120,14 @@ const createMpv = async (data: {
}): Promise<MpvAPI> => {
const { binaryPath, extraParameters, properties } = data;
const resolvedBinaryPath = await resolveMpvBinaryPath(binaryPath);
const normalizedExtraParameters = (extraParameters ?? [])
.map((param) => param.trim())
.filter((param) => param.length > 0);
const params = uniq([...DEFAULT_MPV_PARAMETERS(extraParameters), ...(extraParameters || [])]);
const params = uniq([
...DEFAULT_MPV_PARAMETERS(normalizedExtraParameters),
...normalizedExtraParameters,
]);
const mpv = new MpvAPI(
{
+1 -1
View File
@@ -335,7 +335,7 @@ if (isDevelopment) {
}
const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets')
? path.join(path.dirname(app.getAppPath()), 'assets')
: path.join(__dirname, '../../assets');
const getAssetPath = (...paths: string[]): string => {
@@ -411,8 +411,12 @@ export const JellyfinController: InternalControllerEndpoint = {
throw new Error('Failed to get album detail');
}
// Workaround for Jellyfin bug that returns items that share the same album name
const albumIdSet = new Set([query.id]);
const songs = songsRes.body.Items.filter((item) => albumIdSet.has(item.AlbumId!));
return jfNormalize.album(
{ ...res.body, Songs: songsRes.body.Items },
{ ...res.body, Songs: songs },
apiClientProps.server,
args.context?.pathReplace,
args.context?.pathReplaceWith,
@@ -44,6 +44,7 @@ import { FavoriteColumn } from '/@/renderer/components/item-list/item-table-list
import { GenreBadgeColumn } from '/@/renderer/components/item-list/item-table-list/columns/genre-badge-column';
import { GenreColumn } from '/@/renderer/components/item-list/item-table-list/columns/genre-column';
import { ImageColumn } from '/@/renderer/components/item-list/item-table-list/columns/image-column';
import { NumericColumn } from '/@/renderer/components/item-list/item-table-list/columns/numeric-column';
import { PathColumn } from '/@/renderer/components/item-list/item-table-list/columns/path-column';
import { PlaylistReorderColumn } from '/@/renderer/components/item-list/item-table-list/columns/playlist-reorder-column';
import { RatingColumn } from '/@/renderer/components/item-list/item-table-list/columns/rating-column';
@@ -239,10 +240,7 @@ const ItemTableListColumnBase = (props: ItemTableListColumn) => {
case TableColumn.CHANNELS:
case TableColumn.DISC_NUMBER:
case TableColumn.SAMPLE_RATE:
case TableColumn.TRACK_NUMBER:
return (
<TrackNumberColumn {...props} {...dragProps} controls={controls} type={type} />
);
return <NumericColumn {...props} {...dragProps} controls={controls} type={type} />;
case TableColumn.COMPOSER:
return <ComposerColumn {...props} {...dragProps} controls={controls} type={type} />;
@@ -304,6 +302,11 @@ const ItemTableListColumnBase = (props: ItemTableListColumn) => {
/>
);
case TableColumn.TRACK_NUMBER:
return (
<TrackNumberColumn {...props} {...dragProps} controls={controls} type={type} />
);
case TableColumn.USER_FAVORITE:
return <FavoriteColumn {...props} {...dragProps} controls={controls} type={type} />;
@@ -5,6 +5,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
import { api } from '/@/renderer/api';
import { useItemImageUrl } from '/@/renderer/components/item-image/item-image';
import { usePlayerEvents } from '/@/renderer/features/player/audio-player/hooks/use-player-events';
import {
useIsRadioActive,
useRadioPlayer,
@@ -36,6 +37,7 @@ const DiscordStatusDisplayType = {
} as const;
type ActivityState = [QueueSong | undefined, number, PlayerStatus];
type ActivityTrigger = 'initial' | 'interval' | 'seek' | 'status_change' | 'track_change';
const MAX_FIELD_LENGTH = 127;
const MAX_URL_LENGTH = 256;
@@ -64,22 +66,24 @@ export const useDiscordRpc = () => {
const imageUrlRef = useRef<null | string | undefined>(imageUrl);
const previousEnabledRef = useRef<boolean>(discordSettings.enabled);
const intervalRef = useRef<NodeJS.Timeout | null>(null);
const previousActivityStateRef = useRef<ActivityState | null>(null);
const discordEnabledRef = useRef<boolean>(discordSettings.enabled);
const privateModeRef = useRef<boolean>(privateMode);
// Update imageUrl ref when it changes
useEffect(() => {
imageUrlRef.current = imageUrl;
}, [imageUrl]);
useEffect(() => {
discordEnabledRef.current = discordSettings.enabled;
}, [discordSettings.enabled]);
useEffect(() => {
privateModeRef.current = privateMode;
}, [privateMode]);
const setActivity = useCallback(
async (current: ActivityState, previous: ActivityState) => {
// Check if track changed by comparing with previous state
async (current: ActivityState, trigger: ActivityTrigger) => {
const song = current[0];
const previousSong = previous[0];
const trackChangedByState =
song && previousSong
? song._uniqueId !== previousSong._uniqueId
: song !== previousSong;
const trackChanged = song ? lastUniqueId !== song._uniqueId : false;
const isPlayingRadio = isRadioActive && isRadioPlaying;
@@ -103,6 +107,7 @@ export const useDiscordRpc = () => {
meta: {
reason,
status: current[2],
trigger,
},
});
return discordRpc?.clearActivity();
@@ -152,6 +157,7 @@ export const useDiscordRpc = () => {
showAsListening: discordSettings.showAsListening,
stationName: stationName || 'Radio',
title,
trigger,
},
});
discordRpc?.setActivity(activity);
@@ -162,214 +168,177 @@ export const useDiscordRpc = () => {
return;
}
/*
1. If the song has just started, update status
2. If we jump more then 1.2 seconds from last state, update status to match
3. If the current song id is completely different, update status
4. If the player state changed, update status
*/
if (trackChanged) {
logFn.debug(logMsg[LogCategory.EXTERNAL].discordRpcTrackChanged, {
category: LogCategory.EXTERNAL,
meta: {
artistName: song.artists?.[0]?.name,
songId: song._uniqueId,
songName: song.name,
},
});
setlastUniqueId(song._uniqueId);
}
const reason = trigger;
const start = Math.round(Date.now() - current[1] * 1000);
const end = Math.round(start + song.duration);
const artists = song?.artists.map((artist) => artist.name).join(', ');
const statusDisplayMap = {
[DiscordDisplayType.ARTIST_NAME]: DiscordStatusDisplayType.STATE,
[DiscordDisplayType.FEISHIN]: DiscordStatusDisplayType.NAME,
[DiscordDisplayType.SONG_NAME]: DiscordStatusDisplayType.DETAILS,
};
const activity: SetActivity = {
details: truncate((song?.name && song.name.padEnd(2, ' ')) || 'Idle'),
instance: false,
largeImageKey: undefined,
largeImageText: truncate(
(song?.album && song.album.padEnd(2, ' ')) || 'Unknown album',
),
smallImageKey: undefined,
smallImageText: undefined,
state: truncate((artists && artists.padEnd(2, ' ')) || 'Unknown artist'),
statusDisplayType: statusDisplayMap[discordSettings.displayType],
// I would love to use the actual type as opposed to hardcoding to 2,
// but manually installing the discord-types package appears to break things
type: discordSettings.showAsListening ? 2 : 0,
};
if (
previous[1] === 0 ||
Math.abs(current[1] - previous[1]) > 1.2 ||
trackChangedByState ||
trackChanged ||
current[2] !== previous[2]
(discordSettings.linkType == DiscordLinkType.LAST_FM ||
discordSettings.linkType == DiscordLinkType.MBZ_LAST_FM) &&
song?.artistName
) {
if (trackChangedByState || trackChanged) {
logFn.debug(logMsg[LogCategory.EXTERNAL].discordRpcTrackChanged, {
category: LogCategory.EXTERNAL,
meta: {
artistName: song.artists?.[0]?.name,
songId: song._uniqueId,
songName: song.name,
},
});
setlastUniqueId(song._uniqueId);
activity.stateUrl =
'https://www.last.fm/music/' + encodeURIComponent(song.artists[0].name);
const detailsUrl =
'https://www.last.fm/music/' +
encodeURIComponent(song.albumArtists[0].name) +
'/' +
encodeURIComponent(song.album || '_') +
'/' +
encodeURIComponent(song.name);
// The details URL has a max length, only set it if it doesn't exceed it
if (detailsUrl.length <= MAX_URL_LENGTH) {
activity.detailsUrl = detailsUrl;
}
}
if (
discordSettings.linkType == DiscordLinkType.MBZ ||
discordSettings.linkType == DiscordLinkType.MBZ_LAST_FM
) {
if (song?.mbzTrackId) {
activity.detailsUrl = 'https://musicbrainz.org/track/' + song.mbzTrackId;
} else if (song?.mbzRecordingId) {
activity.detailsUrl =
'https://musicbrainz.org/recording/' + song.mbzRecordingId;
}
}
if (current[2] === PlayerStatus.PLAYING) {
if (start && end) {
activity.startTimestamp = start;
activity.endTimestamp = end;
}
let reason: string;
if (trackChangedByState || trackChanged) {
reason = 'track_changed';
} else if (previous[1] === 0) {
reason = 'song_started';
} else if (Math.abs(current[1] - previous[1]) > 1.2) {
reason = 'time_jump';
} else {
reason = 'player_state_changed';
}
const start = Math.round(Date.now() - current[1] * 1000);
const end = Math.round(start + song.duration);
const artists = song?.artists.map((artist) => artist.name).join(', ');
const statusDisplayMap = {
[DiscordDisplayType.ARTIST_NAME]: DiscordStatusDisplayType.STATE,
[DiscordDisplayType.FEISHIN]: DiscordStatusDisplayType.NAME,
[DiscordDisplayType.SONG_NAME]: DiscordStatusDisplayType.DETAILS,
};
const activity: SetActivity = {
details: truncate((song?.name && song.name.padEnd(2, ' ')) || 'Idle'),
instance: false,
largeImageKey: undefined,
largeImageText: truncate(
(song?.album && song.album.padEnd(2, ' ')) || 'Unknown album',
),
smallImageKey: undefined,
smallImageText: undefined,
state: truncate((artists && artists.padEnd(2, ' ')) || 'Unknown artist'),
statusDisplayType: statusDisplayMap[discordSettings.displayType],
// I would love to use the actual type as opposed to hardcoding to 2,
// but manually installing the discord-types package appears to break things
type: discordSettings.showAsListening ? 2 : 0,
};
if (
(discordSettings.linkType == DiscordLinkType.LAST_FM ||
discordSettings.linkType == DiscordLinkType.MBZ_LAST_FM) &&
song?.artistName
) {
activity.stateUrl =
'https://www.last.fm/music/' + encodeURIComponent(song.artists[0].name);
const detailsUrl =
'https://www.last.fm/music/' +
encodeURIComponent(song.albumArtists[0].name) +
'/' +
encodeURIComponent(song.album || '_') +
'/' +
encodeURIComponent(song.name);
// The details URL has a max length, only set it if it doesn't exceed it
if (detailsUrl.length <= MAX_URL_LENGTH) {
activity.detailsUrl = detailsUrl;
}
}
if (
discordSettings.linkType == DiscordLinkType.MBZ ||
discordSettings.linkType == DiscordLinkType.MBZ_LAST_FM
) {
if (song?.mbzTrackId) {
activity.detailsUrl = 'https://musicbrainz.org/track/' + song.mbzTrackId;
} else if (song?.mbzRecordingId) {
activity.detailsUrl =
'https://musicbrainz.org/recording/' + song.mbzRecordingId;
}
}
if (current[2] === PlayerStatus.PLAYING) {
if (start && end) {
activity.startTimestamp = start;
activity.endTimestamp = end;
}
if (discordSettings.showStateIcon) {
activity.smallImageKey = 'playing';
activity.smallImageText = sentenceCase(current[2]);
}
} else {
activity.smallImageKey = 'paused';
if (discordSettings.showStateIcon) {
activity.smallImageKey = 'playing';
activity.smallImageText = sentenceCase(current[2]);
}
} else {
activity.smallImageKey = 'paused';
activity.smallImageText = sentenceCase(current[2]);
}
if (discordSettings.showServerImage && song) {
if (song._uniqueId === currentSong?._uniqueId && imageUrlRef.current) {
if (song._serverType === ServerType.JELLYFIN) {
activity.largeImageKey = imageUrlRef.current;
} else if (
song._serverType === ServerType.NAVIDROME ||
song._serverType === ServerType.SUBSONIC
) {
try {
const info = await api.controller.getAlbumInfo({
apiClientProps: {
forceRemoteUrl: true,
serverId: song._serverId,
},
query: { id: song.albumId },
});
if (discordSettings.showServerImage && song) {
if (song._uniqueId === currentSong?._uniqueId && imageUrlRef.current) {
if (song._serverType === ServerType.JELLYFIN) {
activity.largeImageKey = imageUrlRef.current;
} else if (
song._serverType === ServerType.NAVIDROME ||
song._serverType === ServerType.SUBSONIC
) {
try {
const info = await api.controller.getAlbumInfo({
apiClientProps: {
forceRemoteUrl: true,
serverId: song._serverId,
},
query: { id: song.albumId },
});
if (info.imageUrl) {
activity.largeImageKey = info.imageUrl;
}
} catch {
/* empty */
if (info.imageUrl) {
activity.largeImageKey = info.imageUrl;
}
} catch {
/* empty */
}
}
}
if (
activity.largeImageKey === undefined &&
lastfmApiKey &&
song?.album &&
song?.albumArtists.length
) {
const albumInfo = await fetch(
`https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=${lastfmApiKey}&artist=${encodeURIComponent(song.albumArtists[0].name)}&album=${encodeURIComponent(song.album)}&format=json`,
);
const albumInfoJson = await albumInfo.json();
if (albumInfoJson.album?.image?.[3]['#text']) {
activity.largeImageKey = albumInfoJson.album.image[3]['#text'];
}
}
// Fall back to default icon if not set
if (!activity.largeImageKey) {
activity.largeImageKey = 'icon';
}
// Initialize if needed
const isConnected = await discordRpc?.isConnected();
if (!isConnected) {
logFn.debug(logMsg[LogCategory.EXTERNAL].discordRpcInitialized, {
category: LogCategory.EXTERNAL,
meta: {
clientId: discordSettings.clientId,
},
});
previousEnabledRef.current = true;
await discordRpc?.initialize(discordSettings.clientId);
}
logFn.debug(logMsg[LogCategory.EXTERNAL].discordRpcSetActivity, {
category: LogCategory.EXTERNAL,
meta: {
albumName: song.album,
artistName: song.artists?.[0]?.name,
currentStatus: current[2],
currentTime: current[1],
displayType: discordSettings.displayType,
hasLargeImage: !!activity.largeImageKey,
hasTimestamps: !!(activity.startTimestamp && activity.endTimestamp),
previousStatus: previous[2],
previousTime: previous[1],
reason,
showAsListening: discordSettings.showAsListening,
songName: song.name,
trackChanged: trackChangedByState || trackChanged,
},
});
discordRpc?.setActivity(activity);
} else {
logFn.debug(logMsg[LogCategory.EXTERNAL].discordRpcUpdateSkipped, {
category: LogCategory.EXTERNAL,
meta: {
currentStatus: current[2],
currentTime: current[1],
previousStatus: previous[2],
previousTime: previous[1],
timeDiff: Math.abs(current[1] - previous[1]),
trackChanged: trackChangedByState || trackChanged,
},
});
}
if (
activity.largeImageKey === undefined &&
lastfmApiKey &&
song?.album &&
song?.albumArtists.length
) {
const albumInfo = await fetch(
`https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=${lastfmApiKey}&artist=${encodeURIComponent(song.albumArtists[0].name)}&album=${encodeURIComponent(song.album)}&format=json`,
);
const albumInfoJson = await albumInfo.json();
if (albumInfoJson.album?.image?.[3]['#text']) {
activity.largeImageKey = albumInfoJson.album.image[3]['#text'];
}
}
// Fall back to default icon if not set
if (!activity.largeImageKey) {
activity.largeImageKey = 'icon';
}
// Initialize if needed
const isConnected = await discordRpc?.isConnected();
if (!isConnected) {
logFn.debug(logMsg[LogCategory.EXTERNAL].discordRpcInitialized, {
category: LogCategory.EXTERNAL,
meta: {
clientId: discordSettings.clientId,
},
});
previousEnabledRef.current = true;
await discordRpc?.initialize(discordSettings.clientId);
}
logFn.debug(logMsg[LogCategory.EXTERNAL].discordRpcSetActivity, {
category: LogCategory.EXTERNAL,
meta: {
albumName: song.album,
artistName: song.artists?.[0]?.name,
currentStatus: current[2],
currentTime: current[1],
displayType: discordSettings.displayType,
hasLargeImage: !!activity.largeImageKey,
hasTimestamps: !!(activity.startTimestamp && activity.endTimestamp),
reason,
showAsListening: discordSettings.showAsListening,
songName: song.name,
trackChanged,
trigger,
},
});
discordRpc?.setActivity(activity);
},
[
discordSettings.showAsListening,
@@ -390,7 +359,7 @@ export const useDiscordRpc = () => {
],
);
const debouncedSetActivity = useDebouncedCallback(setActivity, 500);
const debouncedSetActivity = useDebouncedCallback(setActivity, 1000);
// Quit Discord RPC if it was enabled and is now disabled
useEffect(() => {
@@ -409,95 +378,110 @@ export const useDiscordRpc = () => {
}
}, [discordSettings.clientId, privateMode, discordSettings.enabled]);
const getCurrentActivityState = useCallback((): ActivityState => {
const state = usePlayerStore.getState();
return [
state.getCurrentSong(),
useTimestampStoreBase.getState().timestamp,
state.player.status,
];
}, []);
const clearRefreshInterval = useCallback(() => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
}, []);
const emitActivityUpdateRef = useRef<(next: ActivityState, trigger: ActivityTrigger) => void>(
() => {},
);
const resetRefreshInterval = useCallback(() => {
clearRefreshInterval();
intervalRef.current = setInterval(() => {
const current = getCurrentActivityState();
emitActivityUpdateRef.current(current, 'interval');
}, 15000);
}, [clearRefreshInterval, getCurrentActivityState]);
const emitActivityUpdate = useCallback(
(next: ActivityState, trigger: ActivityTrigger) => {
debouncedSetActivity(next, trigger);
resetRefreshInterval();
},
[debouncedSetActivity, resetRefreshInterval],
);
useEffect(() => {
emitActivityUpdateRef.current = emitActivityUpdate;
}, [emitActivityUpdate]);
useEffect(() => {
if (!discordSettings.enabled || privateMode) {
clearRefreshInterval();
return;
}
const getCurrentActivityState = (): ActivityState => {
const state = usePlayerStore.getState();
const currentSong = state.getCurrentSong();
const currentTime = useTimestampStoreBase.getState().timestamp;
const status = state.player.status;
return [currentSong, currentTime, status];
};
const resetInterval = () => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
intervalRef.current = setInterval(() => {
const current = getCurrentActivityState();
const previous = previousActivityStateRef.current || current;
debouncedSetActivity(current, previous);
previousActivityStateRef.current = current;
}, 15000);
};
resetInterval();
const initialState = getCurrentActivityState();
let previousUniqueId = initialState[0]?._uniqueId || '';
previousActivityStateRef.current = initialState;
// Set activity immediately when Discord RPC is enabled
debouncedSetActivity(initialState, initialState);
const unsubSongChange = usePlayerStore.subscribe(
(state): ActivityState => {
const currentSong = state.getCurrentSong();
const currentTime = useTimestampStoreBase.getState().timestamp;
const status = state.player.status;
return [currentSong, currentTime, status];
},
(current, previous) => {
const currentUniqueId = current[0]?._uniqueId || '';
const trackChanged = previousUniqueId !== currentUniqueId;
if (trackChanged && current[0]) {
resetInterval();
previousUniqueId = currentUniqueId;
}
const activity: ActivityState = [
current[0] as QueueSong,
current[1] as number,
current[2] as PlayerStatus,
];
// Use the ref as the source of truth for previous state
const previousActivity: ActivityState =
previousActivityStateRef.current ||
(previous
? [
previous[0] as QueueSong,
previous[1] as number,
previous[2] as PlayerStatus,
]
: activity);
debouncedSetActivity(activity, previousActivity);
previousActivityStateRef.current = activity;
},
);
emitActivityUpdate(initialState, 'initial');
return () => {
unsubSongChange();
if (intervalRef.current) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
clearRefreshInterval();
};
}, [
debouncedSetActivity,
discordSettings.clientId,
clearRefreshInterval,
discordSettings.enabled,
emitActivityUpdate,
getCurrentActivityState,
privateMode,
setActivity,
]);
usePlayerEvents(
{
onCurrentSongChange: ({ song }) => {
if (!discordEnabledRef.current || privateModeRef.current) {
return;
}
const playerState = usePlayerStore.getState();
const activityState: ActivityState = [
song,
useTimestampStoreBase.getState().timestamp,
playerState.player.status,
];
emitActivityUpdateRef.current(activityState, 'track_change');
},
onPlayerSeekToTimestamp: ({ timestamp }) => {
if (!discordEnabledRef.current || privateModeRef.current) {
return;
}
const playerState = usePlayerStore.getState();
const activityState: ActivityState = [
playerState.getCurrentSong(),
timestamp,
playerState.player.status,
];
emitActivityUpdateRef.current(activityState, 'seek');
},
onPlayerStatus: ({ status }) => {
if (!discordEnabledRef.current || privateModeRef.current) {
return;
}
const playerState = usePlayerStore.getState();
const activityState: ActivityState = [
playerState.getCurrentSong(),
useTimestampStoreBase.getState().timestamp,
status,
];
emitActivityUpdateRef.current(activityState, 'status_change');
},
},
[],
);
};
const DiscordRpcHookInner = () => {
@@ -214,7 +214,14 @@ export const SidebarPlayQueue = () => {
))}
</SplitPane>
) : (
<Stack gap={0} h="100%" w="100%">
<Stack
gap={0}
style={{
flex: 1,
minHeight: 0,
}}
w="100%"
>
<PlayQueueListControls
handleSearch={setSearch}
searchTerm={search}
@@ -8,7 +8,7 @@ import { QueueSong } from '/@/shared/types/domain-types';
export function useSongUrl(
song: QueueSong | undefined,
current: boolean,
transcode: TranscodingConfig,
transcode: Partial<TranscodingConfig>,
): string | undefined {
const prior = useRef(['', '']);
const shouldReusePrior = Boolean(
@@ -24,7 +24,7 @@ export function useSongUrl(
bitrate: transcode.bitrate,
format: transcode.format,
id: song!.id,
transcode: transcode.enabled,
transcode: transcode.enabled ?? false,
},
}),
queryKey: [
@@ -63,7 +63,7 @@ export function useSongUrl(
export const getSongUrl = async (
song: QueueSong,
transcode: TranscodingConfig,
transcode: Partial<TranscodingConfig>,
skipAutoTranscode?: boolean,
) => {
const url = await api.controller.getStreamUrl({
@@ -73,7 +73,7 @@ export const getSongUrl = async (
format: transcode.format,
id: song.id,
skipAutoTranscode,
transcode: transcode.enabled,
transcode: transcode.enabled ?? false,
},
});
@@ -153,6 +153,7 @@ export function WebPlayer() {
gaplessHandler({
currentTime: e.playedSeconds,
duration: getDuration(playerRef.current.player1().ref),
hasNextSong: Boolean(player2),
isFlac: false,
isTransitioning,
nextPlayer: playerRef.current.player2(),
@@ -206,6 +207,7 @@ export function WebPlayer() {
gaplessHandler({
currentTime: e.playedSeconds,
duration: getDuration(playerRef.current.player2().ref),
hasNextSong: Boolean(player1),
isFlac: false,
isTransitioning,
nextPlayer: playerRef.current.player1(),
@@ -680,6 +682,7 @@ function exponentialEaseOut(t: number): number {
function gaplessHandler(args: {
currentTime: number;
duration: number;
hasNextSong: boolean;
isFlac: boolean;
isTransitioning: boolean | string;
nextPlayer: {
@@ -688,7 +691,19 @@ function gaplessHandler(args: {
};
setIsTransitioning: Dispatch<boolean | string>;
}) {
const { currentTime, duration, isFlac, isTransitioning, nextPlayer, setIsTransitioning } = args;
const {
currentTime,
duration,
hasNextSong,
isFlac,
isTransitioning,
nextPlayer,
setIsTransitioning,
} = args;
if (!hasNextSong) {
return null;
}
if (!isTransitioning) {
if (currentTime > duration - 2) {
@@ -9,7 +9,13 @@ import styles from './playerbar-waveform.module.css';
import { useSongUrl } from '/@/renderer/features/player/audio-player/hooks/use-stream-url';
import { PlayerbarSeekSlider } from '/@/renderer/features/player/components/playerbar-seek-slider';
import { usePlayer } from '/@/renderer/features/player/context/player-context';
import { BarAlign, usePlayerbarSlider, usePlayerSong, usePlayerTimestamp } from '/@/renderer/store';
import {
BarAlign,
usePlaybackSettings,
usePlayerbarSlider,
usePlayerSong,
usePlayerTimestamp,
} from '/@/renderer/store';
import { useAppThemeColors, useColorScheme } from '/@/renderer/themes/use-app-theme';
import { Text } from '/@/shared/components/text/text';
@@ -30,7 +36,12 @@ export const PlayerbarWaveform = () => {
const songDuration = currentSong?.duration ? currentSong.duration / 1000 : 0;
const streamUrl = useSongUrl(currentSong, true, { bitrate: 64, enabled: false, format: 'mp3' });
const { transcode } = usePlaybackSettings();
const streamUrl = useSongUrl(currentSong, true, {
bitrate: 64,
enabled: transcode.enabled,
format: 'mp3',
});
const { color } = useAppThemeColors();
const primaryColor = (color['--theme-colors-primary'] as string) || 'rgb(53, 116, 252)';
@@ -61,7 +61,7 @@ export const ScrobbleStatus = ({ formattedTime }: { formattedTime: string }) =>
);
return (
<HoverCard position="top" width={280}>
<HoverCard openDelay={500} position="top" width={280}>
<HoverCard.Target>
<Group
align="center"
@@ -180,9 +180,6 @@ export const useScrobble = () => {
const currentSong = usePlayerStore.getState().getCurrentSong();
const mediaType = currentSong?._itemType.includes('song') ? 'song' : 'podcast';
const serverId = currentSong?._serverId;
const server = getServerById(serverId);
const hasPlaybackReport = hasFeature(server, ServerFeature.REPORT_PLAYBACK);
const useTicks = currentSong?._serverType === ServerType.JELLYFIN;
const currentStatus = usePlayerStore.getState().player.status;
const currentTime = properties.timestamp;
@@ -239,36 +236,36 @@ export const useScrobble = () => {
}
// Send progress events every 10 seconds
if (hasPlaybackReport) {
const timeSinceLastProgress = currentTime - lastProgressEventRef.current;
if (timeSinceLastProgress >= 10) {
sendScrobble.mutate(
{
apiClientProps: { serverId: serverId || '' },
query: {
albumId: currentSong.albumId,
event: 'timeupdate',
id: currentSong.id,
mediaType: mediaType,
playbackRate,
position: getPositionValue(currentTime, useTicks),
submission: false,
},
},
{
onSuccess: () => {
logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledTimeupdate, {
category: LogCategory.SCROBBLE,
meta: {
id: currentSong.id,
},
});
},
},
);
lastProgressEventRef.current = currentTime;
}
}
// if (hasPlaybackReport) {
// const timeSinceLastProgress = currentTime - lastProgressEventRef.current;
// if (timeSinceLastProgress >= 10) {
// sendScrobble.mutate(
// {
// apiClientProps: { serverId: serverId || '' },
// query: {
// albumId: currentSong.albumId,
// event: 'timeupdate',
// id: currentSong.id,
// mediaType: mediaType,
// playbackRate,
// position: getPositionValue(currentTime, useTicks),
// submission: false,
// },
// },
// {
// onSuccess: () => {
// logFn.debug(logMsg[LogCategory.SCROBBLE].scrobbledTimeupdate, {
// category: LogCategory.SCROBBLE,
// meta: {
// id: currentSong.id,
// },
// });
// },
// },
// );
// lastProgressEventRef.current = currentTime;
// }
// }
// Check if we should submit scrobble based on listened time
if (!isCurrentSongScrobbledRef.current) {
@@ -74,6 +74,7 @@ export const PlaylistListInfiniteTable = ({
columns={columns}
data={loadedItems}
enableAlternateRowColors={enableAlternateRowColors}
enableExpansion={false}
enableHeader={enableHeader}
enableHorizontalBorders={enableHorizontalBorders}
enableRowHoverHighlight={enableRowHoverHighlight}
@@ -87,6 +87,7 @@ export const PlaylistListPaginatedTable = ({
columns={columns}
data={data || []}
enableAlternateRowColors={enableAlternateRowColors}
enableExpansion={false}
enableHeader={enableHeader}
enableHorizontalBorders={enableHorizontalBorders}
enableRowHoverHighlight={enableRowHoverHighlight}
@@ -18,6 +18,10 @@ import { Checkbox } from '/@/shared/components/checkbox/checkbox';
import { Icon } from '/@/shared/components/icon/icon';
import { Table } from '/@/shared/components/table/table';
import { TextInput } from '/@/shared/components/text-input/text-input';
import {
keyboardCodeToHotkeyKey,
MODIFIER_KEY_CODES,
} from '/@/shared/utils/keyboard-code-to-hotkey';
const ipc = isElectron() ? window.api.ipc : null;
@@ -112,25 +116,16 @@ export const HotkeyManagerSettings = memo(() => {
const debouncedSetHotkey = debounce(
(binding: BindingActions, e: KeyboardEvent<HTMLInputElement>) => {
e.preventDefault();
const IGNORED_KEYS = ['Control', 'Alt', 'Shift', 'Meta', ' ', 'Escape'];
const keys: string[] = [];
if (e.ctrlKey) keys.push('mod');
if (e.altKey) keys.push('alt');
if (e.shiftKey) keys.push('shift');
if (e.metaKey) keys.push('meta');
if (e.key === ' ') keys.push('space');
if (!IGNORED_KEYS.includes(e.key)) {
if (e.code.includes('Numpad')) {
if (e.key === '+') keys.push('numpadadd');
else if (e.key === '-') keys.push('numpadsubtract');
else if (e.key === '*') keys.push('numpadmultiply');
else if (e.key === '/') keys.push('numpaddivide');
else if (e.key === '.') keys.push('numpaddecimal');
else keys.push(`numpad${e.key}`.toLowerCase());
} else if (e.key === '+') {
keys.push('equal');
} else {
keys.push(e.key?.toLowerCase());
if (!MODIFIER_KEY_CODES.has(e.code) && e.code !== 'Escape') {
const hotkeyKey = keyboardCodeToHotkeyKey(e.code);
if (hotkeyKey) {
keys.push(hotkeyKey);
}
}
@@ -36,13 +36,12 @@ export const WindowSettings = memo(() => {
if (!e) return;
// Platform.LINUX is used as the native frame option regardless of the actual platform
const hasFrame = localSettings?.get('window_has_frame') as
| boolean
| undefined;
const isSwitchingToFrame = !hasFrame && e === Platform.LINUX;
const isSwitchingToNoFrame = hasFrame && e !== Platform.LINUX;
const requireRestart = isSwitchingToFrame || isSwitchingToNoFrame;
const previousWindowBarStyle = settings.windowBarStyle;
const isSwitchingToNative =
previousWindowBarStyle !== Platform.LINUX && e === Platform.LINUX;
const isSwitchingFromNative =
previousWindowBarStyle === Platform.LINUX && e !== Platform.LINUX;
const requireRestart = isSwitchingToNative || isSwitchingFromNative;
if (requireRestart) {
openRestartRequiredToast();
+5 -1
View File
@@ -2,8 +2,10 @@ import {
type HotkeyItem as MantineHotkeyItem,
useHotkeys as useMantineHotkeys,
} from '@mantine/hooks';
import { useMemo } from 'react';
import { useAppStore } from '/@/renderer/store';
import { withPhysicalKeys } from '/@/shared/utils/hotkeys';
const EMPTY_HOTKEYS: MantineHotkeyItem[] = [];
@@ -13,8 +15,10 @@ export const useHotkeys = (
triggerOnContentEditable?: boolean,
) => {
const commandPaletteOpened = useAppStore((state) => state.commandPalette.opened);
const physicalHotkeys = useMemo(() => withPhysicalKeys(hotkeys), [hotkeys]);
useMantineHotkeys(
commandPaletteOpened ? EMPTY_HOTKEYS : hotkeys,
commandPaletteOpened ? EMPTY_HOTKEYS : physicalHotkeys,
tagsToIgnore,
triggerOnContentEditable,
);
+6 -4
View File
@@ -223,7 +223,7 @@ function calculateNextIndex(
} else {
// Repeat none: move to next track, or pause if at the end
if (isLastTrack) {
return { nextIndex: 0, shouldPause: true };
return { nextIndex: currentIndex, shouldPause: true };
} else {
return { nextIndex: currentIndex + 1, shouldPause: false };
}
@@ -939,10 +939,12 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
const pauseOnNext = player.pauseOnNextSongEnd;
const newStatus =
shouldPause || pauseOnNext ? PlayerStatus.PAUSED : PlayerStatus.PLAYING;
const shouldKeepCurrentPlayer = newStatus === PlayerStatus.PAUSED;
const shouldSwapPlayer = !isRepeatOneSameTrack && !shouldKeepCurrentPlayer;
set((state) => {
state.player.index = nextPlaybackIndex;
state.player.playerNum = newPlayerNum;
state.player.playerNum = shouldSwapPlayer ? newPlayerNum : player.playerNum;
setTimestampStore(0);
state.player.status = newStatus;
@@ -999,7 +1001,7 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
}
const { player1, player2 } = getDualPlayerSongs(
newPlayerNum,
shouldSwapPlayer ? newPlayerNum : player.playerNum,
currentSong,
nextSong,
repeat,
@@ -1009,7 +1011,7 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
currentSong,
index: currentQueueIndex,
nextSong,
num: newPlayerNum,
num: shouldSwapPlayer ? newPlayerNum : player.playerNum,
player1,
player2,
previousSong,
+11 -1
View File
@@ -2,7 +2,17 @@ import {
type HotkeyItem as MantineHotkeyItem,
useHotkeys as useMantineHotkeys,
} from '@mantine/hooks';
import { useMemo } from 'react';
export const useHotkeys = useMantineHotkeys;
import { withPhysicalKeys } from '/@/shared/utils/hotkeys';
export const useHotkeys = (
hotkeys: MantineHotkeyItem[],
tagsToIgnore?: string[],
triggerOnContentEditable?: boolean,
) => {
const physicalHotkeys = useMemo(() => withPhysicalKeys(hotkeys), [hotkeys]);
useMantineHotkeys(physicalHotkeys, tagsToIgnore, triggerOnContentEditable);
};
export type HotkeyItem = MantineHotkeyItem;
+37
View File
@@ -0,0 +1,37 @@
import type { HotkeyItem } from '@mantine/hooks';
const RESERVED_KEYS = new Set(['alt', 'ctrl', 'meta', 'mod', 'shift']);
/**
* Converts stored hotkey strings to Mantine's physical-key format.
* Mantine matches KeyboardEvent.code via normalizeKey, which turns Digit1 into
* "digit1" but leaves "1" as "1" so mod+1 must become mod+Digit1.
*/
export const toPhysicalHotkey = (hotkey: string): string =>
hotkey
.split('+')
.map((part) => part.trim())
.map((part) => {
if (part === '[plus]') {
return part;
}
const lower = part.toLowerCase();
if (RESERVED_KEYS.has(lower)) {
return lower;
}
if (/^\d$/.test(part)) {
return `Digit${part}`;
}
return part;
})
.join('+');
export const withPhysicalKeys = (hotkeys: HotkeyItem[]): HotkeyItem[] =>
hotkeys.map(([hotkey, handler, options]) => [
toPhysicalHotkey(hotkey),
handler,
{ ...options, usePhysicalKeys: true },
]);
@@ -0,0 +1,68 @@
const CODE_TO_HOTKEY_KEY: Record<string, string> = {
ArrowDown: 'arrowdown',
ArrowLeft: 'arrowleft',
ArrowRight: 'arrowright',
ArrowUp: 'arrowup',
Backspace: 'backspace',
Delete: 'delete',
End: 'end',
Enter: 'enter',
Equal: 'equal',
Escape: 'escape',
Home: 'home',
Insert: 'insert',
Minus: 'minus',
PageDown: 'pagedown',
PageUp: 'pageup',
Space: 'space',
Tab: 'tab',
};
const NUMPAD_CODE_TO_HOTKEY_KEY: Record<string, string> = {
Add: 'numpadadd',
Decimal: 'numpaddecimal',
Divide: 'numpaddivide',
Enter: 'numpadenter',
Multiply: 'numpadmultiply',
Subtract: 'numpadsubtract',
};
export const MODIFIER_KEY_CODES = new Set([
'AltLeft',
'AltRight',
'ControlLeft',
'ControlRight',
'MetaLeft',
'MetaRight',
'ShiftLeft',
'ShiftRight',
]);
export const keyboardCodeToHotkeyKey = (code: string): null | string => {
const mapped = CODE_TO_HOTKEY_KEY[code];
if (mapped) {
return mapped;
}
if (code.startsWith('Key')) {
return code.slice(3).toLowerCase();
}
if (code.startsWith('Digit')) {
return code.slice(5);
}
if (code.startsWith('Numpad')) {
const suffix = code.slice(6);
const numpadMapped = NUMPAD_CODE_TO_HOTKEY_KEY[suffix];
if (numpadMapped) {
return numpadMapped;
}
if (/^\d$/.test(suffix)) {
return `numpad${suffix}`;
}
}
return null;
};