From 000853414e461cbafe35d67ab8ae0cde2c35b770 Mon Sep 17 00:00:00 2001 From: Rick van Lieshout Date: Sun, 5 May 2024 15:09:54 +0200 Subject: [PATCH] feat: switched to TIDAL's universal link format in the entire app --- CHANGELOG.md | 11 +++++++++++ src/scripts/mediaInfo.ts | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a67aed..c6b93f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [next] + +- Implemented TIDAL's universal links. All links are now universal. +- Custom `tidal://` protocol fixed - By [TheRockYT](https://github.com/TheRockYT) +- Global media shortcuts removed since TIDAL includes them by default - By [TheRockYT] + +- Fixes + - [#390](https://github.com/Mastermindzh/tidal-hifi/issues/390) + - [#376](https://github.com/Mastermindzh/tidal-hifi/issues/376) + - [#383](https://github.com/Mastermindzh/tidal-hifi/issues/383) + ## [5.10.0] - TIDAL will now close the previous notification if a new one is sent whilst the old is still visible. [#364](https://github.com/Mastermindzh/tidal-hifi/pull/364) diff --git a/src/scripts/mediaInfo.ts b/src/scripts/mediaInfo.ts index 99917a2..9158355 100644 --- a/src/scripts/mediaInfo.ts +++ b/src/scripts/mediaInfo.ts @@ -19,7 +19,7 @@ export const updateMediaInfo = (arg: MediaInfo) => { mediaInfo.artists = propOrDefault(arg.artists); mediaInfo.album = propOrDefault(arg.album); mediaInfo.icon = propOrDefault(arg.icon); - mediaInfo.url = propOrDefault(arg.url); + mediaInfo.url = toUniversalUrl(propOrDefault(arg.url)); mediaInfo.status = propOrDefault(arg.status); mediaInfo.current = propOrDefault(arg.current); mediaInfo.duration = propOrDefault(arg.duration); @@ -33,5 +33,18 @@ export const updateMediaInfo = (arg: MediaInfo) => { * @param {*} defaultValue defaults to "" */ function propOrDefault(prop: string, defaultValue = "") { - return prop ? prop : defaultValue; + return prop || defaultValue; +} + +/** + * Append the universal link syntax (?u) to any url + * @param url url to append the universal link syntax to + * @returns url with `?u` appended, or the original value of url if falsy + */ +function toUniversalUrl(url: string) { + if (url) { + const queryParamsSet = url.indexOf("?"); + return queryParamsSet > -1 ? `${url}&u` : `${url}?u`; + } + return url; }