From e8d26e450e77d7714d3b0cc5a784014553360d39 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 22 Nov 2023 08:13:06 +0100 Subject: [PATCH 1/7] feat: implement remote https endpoint settings --- src/common/Multiselect/Multiselect.js | 10 ++--- src/routes/Settings/Settings.js | 29 +++++++++++++ .../useStreamingServerSettingsInputs.js | 43 +++++++++++++++++-- src/types/models/Ctx.d.ts | 1 + 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/src/common/Multiselect/Multiselect.js b/src/common/Multiselect/Multiselect.js index df2488a47..a308393e3 100644 --- a/src/common/Multiselect/Multiselect.js +++ b/src/common/Multiselect/Multiselect.js @@ -14,17 +14,13 @@ const Multiselect = ({ className, mode, direction, title, disabled, dataset, ren const [menuOpen, , closeMenu, toggleMenu] = useBinaryState(false); const options = React.useMemo(() => { return Array.isArray(props.options) ? - props.options.filter((option) => { - return option && typeof option.value === 'string'; - }) + props.options : []; }, [props.options]); const selected = React.useMemo(() => { return Array.isArray(props.selected) ? - props.selected.filter((value) => { - return typeof value === 'string'; - }) + props.selected : []; }, [props.selected]); @@ -161,7 +157,7 @@ Multiselect.propTypes = { direction: PropTypes.any, title: PropTypes.string, options: PropTypes.arrayOf(PropTypes.shape({ - value: PropTypes.string.isRequired, + value: PropTypes.string, title: PropTypes.string, label: PropTypes.string })), diff --git a/src/routes/Settings/Settings.js b/src/routes/Settings/Settings.js index 1baeb5511..423594acb 100644 --- a/src/routes/Settings/Settings.js +++ b/src/routes/Settings/Settings.js @@ -45,6 +45,8 @@ const Settings = () => { streamingServerUrlInput } = useProfileSettingsInputs(profile); const { + streamingServerRemoteUrlInput, + remoteEndpointSelect, cacheSizeSelect, torrentProfileSelect } = useStreamingServerSettingsInputs(streamingServer); @@ -531,6 +533,33 @@ const Settings = () => { + { + streamingServerRemoteUrlInput.value !== null ? +
+
+
Remote url
+
+
+
{streamingServerRemoteUrlInput.value}
+
+
+ : + null + } + { + remoteEndpointSelect !== null ? +
+
+
{ t('SETTINGS_HTTPS_ENDPOINT') }
+
+ +
+ : + null + } { cacheSizeSelect !== null ?
diff --git a/src/routes/Settings/useStreamingServerSettingsInputs.js b/src/routes/Settings/useStreamingServerSettingsInputs.js index 442829dbf..5f13f4a0a 100644 --- a/src/routes/Settings/useStreamingServerSettingsInputs.js +++ b/src/routes/Settings/useStreamingServerSettingsInputs.js @@ -54,6 +54,43 @@ const TORRENT_PROFILES = { const useStreamingServerSettingsInputs = (streamingServer) => { const { core } = useServices(); // TODO combine those useMemo in one + + const streamingServerRemoteUrlInput = React.useMemo(() => ({ + value: streamingServer.remoteUrl, + }), [streamingServer.remoteUrl]); + + const remoteEndpointSelect= React.useMemo(() => { + if (streamingServer.settings?.type !== 'Ready' || streamingServer.networkInfo?.type !== 'Ready') { + return null; + } + + return { + options: [ + { + label: 'Disabled', + value: null, + }, + ...streamingServer.networkInfo.content.availableInterfaces.map((address) => ({ + label: address, + value: address, + })) + ], + selected: [streamingServer.settings.content.remoteHttps], + onSelect: (event) => { + core.transport.dispatch({ + action: 'StreamingServer', + args: { + action: 'UpdateSettings', + args: { + ...streamingServer.settings.content, + remoteHttps: event.value, + } + } + }); + } + }; + }, [streamingServer.settings, streamingServer.networkInfo]); + const cacheSizeSelect = React.useMemo(() => { if (streamingServer.settings === null || streamingServer.settings.type !== 'Ready') { return null; @@ -75,7 +112,7 @@ const useStreamingServerSettingsInputs = (streamingServer) => { action: 'UpdateSettings', args: { ...streamingServer.settings.content, - cacheSize: JSON.parse(event.value) + cacheSize: JSON.parse(event.value), } } }); @@ -121,14 +158,14 @@ const useStreamingServerSettingsInputs = (streamingServer) => { action: 'UpdateSettings', args: { ...streamingServer.settings.content, - ...JSON.parse(event.value) + ...JSON.parse(event.value), } } }); } }; }, [streamingServer.settings]); - return { cacheSizeSelect, torrentProfileSelect }; + return { streamingServerRemoteUrlInput, remoteEndpointSelect, cacheSizeSelect, torrentProfileSelect }; }; module.exports = useStreamingServerSettingsInputs; diff --git a/src/types/models/Ctx.d.ts b/src/types/models/Ctx.d.ts index 54ee1dc4e..235d6a6e7 100644 --- a/src/types/models/Ctx.d.ts +++ b/src/types/models/Ctx.d.ts @@ -28,6 +28,7 @@ type Settings = { seekTimeDuration: number, seekShortTimeDuration: number, streamingServerUrl: string, + remoteHttps: string | null, streamingServerWarningDismissed: Date | null, subtitlesBackgroundColor: string, subtitlesBold: boolean, From 5df432c2209e80aa3899effa6b7625a8a7d4207b Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 17 Dec 2023 23:39:27 +0100 Subject: [PATCH 2/7] refactor(Settings): hide remote endpoint select if user is not auth --- src/routes/Settings/Settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/Settings/Settings.js b/src/routes/Settings/Settings.js index 3c7e97ae8..9cdb565f0 100644 --- a/src/routes/Settings/Settings.js +++ b/src/routes/Settings/Settings.js @@ -558,7 +558,7 @@ const Settings = () => { null } { - remoteEndpointSelect !== null ? + profile.auth !== null && profile.auth.user !== null && remoteEndpointSelect !== null ?
{ t('SETTINGS_HTTPS_ENDPOINT') }
From 7ede08f11f45b1396956cd1392925dbde3d538b2 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 17 Dec 2023 23:52:04 +0100 Subject: [PATCH 3/7] feat(Settings): add button to copy remote url to clipboard --- src/routes/Settings/Settings.js | 13 +++++++++++++ .../Settings/useStreamingServerSettingsInputs.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/routes/Settings/Settings.js b/src/routes/Settings/Settings.js index 9cdb565f0..da90b8eaf 100644 --- a/src/routes/Settings/Settings.js +++ b/src/routes/Settings/Settings.js @@ -121,6 +121,16 @@ const Settings = () => { } }); }, []); + const onCopyRemoteUrlClick = React.useCallback(() => { + if (streamingServer.remoteUrl) { + navigator.clipboard.writeText(streamingServer.remoteUrl); + toast.show({ + type: 'success', + title: 'Successfully copied remote url to clipboard', + timeout: 2500, + }); + } + }, [streamingServer.remoteUrl]); const sectionsContainerRef = React.useRef(null); const generalSectionRef = React.useRef(null); const playerSectionRef = React.useRef(null); @@ -552,6 +562,9 @@ const Settings = () => {
{streamingServerRemoteUrlInput.value}
+
: diff --git a/src/routes/Settings/useStreamingServerSettingsInputs.js b/src/routes/Settings/useStreamingServerSettingsInputs.js index 5f13f4a0a..6955ced73 100644 --- a/src/routes/Settings/useStreamingServerSettingsInputs.js +++ b/src/routes/Settings/useStreamingServerSettingsInputs.js @@ -59,7 +59,7 @@ const useStreamingServerSettingsInputs = (streamingServer) => { value: streamingServer.remoteUrl, }), [streamingServer.remoteUrl]); - const remoteEndpointSelect= React.useMemo(() => { + const remoteEndpointSelect = React.useMemo(() => { if (streamingServer.settings?.type !== 'Ready' || streamingServer.networkInfo?.type !== 'Ready') { return null; } From a9e0d3422a3400f3aabc88fd60349b154bdb6715 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 17 Dec 2023 23:52:44 +0100 Subject: [PATCH 4/7] refactor(types): update StreamingServer model types --- src/types/models/StremingServer.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/types/models/StremingServer.d.ts b/src/types/models/StremingServer.d.ts index 4f12f4a76..f44563d9b 100644 --- a/src/types/models/StremingServer.d.ts +++ b/src/types/models/StremingServer.d.ts @@ -93,6 +93,12 @@ type Statistics = { swarmSize: number, }; +type PlaybackDevice = { + id: string, + name: string, + type: string, +}; + type Selected = { transportUrl: string, statistics: { @@ -102,9 +108,11 @@ type Selected = { }; type StreamingServer = { - baseUrl: Loadable | null, + baseUrl: string | null, + remoteUrl: string | null, selected: Selected | null, settings: Loadable | null, torrent: [string, Loadable] | null, statistics: Loadable | null, + playbackDevices: Loadable | null, }; \ No newline at end of file From 7e6911c19cb4a5c2aad648f9f064f06deaef04ce Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 23 Dec 2023 07:24:02 +0100 Subject: [PATCH 5/7] chore: update stremio-core-web --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 99ff58363..50ef9df6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@babel/runtime": "7.16.0", "@sentry/browser": "6.13.3", "@stremio/stremio-colors": "5.0.1", - "@stremio/stremio-core-web": "0.45.0", + "@stremio/stremio-core-web": "0.45.1", "@stremio/stremio-icons": "5.0.0-beta.3", "@stremio/stremio-video": "0.0.26", "a-color-picker": "1.2.1", @@ -3181,9 +3181,9 @@ "integrity": "sha512-Dt3PYmy1DZ473QNs99KYXVWQPHtpIl37VUY0+gCEvvuCqE1fRrZIJtZ9KbysUKonvO7WwdQDztgcW0iGoc1dEA==" }, "node_modules/@stremio/stremio-core-web": { - "version": "0.45.0", - "resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.45.0.tgz", - "integrity": "sha512-3+OBfWHtVWNQZsgq2cEovV/WGd8rP8EAa3pYh5mxGLRVEE+HK7J01YaxLtZBYRRt588fVK79wSklP38x6wY1iQ==", + "version": "0.45.1", + "resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.45.1.tgz", + "integrity": "sha512-aoLsi0Mvd/46V5qz/CSdIle+tvHfRYsLsmNolraze469JLwzNXW1g1ZAAkEDayspwIroqd3QasU//GBgTrvDXg==", "dependencies": { "@babel/runtime": "7.16.0" } @@ -18050,9 +18050,9 @@ "integrity": "sha512-Dt3PYmy1DZ473QNs99KYXVWQPHtpIl37VUY0+gCEvvuCqE1fRrZIJtZ9KbysUKonvO7WwdQDztgcW0iGoc1dEA==" }, "@stremio/stremio-core-web": { - "version": "0.45.0", - "resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.45.0.tgz", - "integrity": "sha512-3+OBfWHtVWNQZsgq2cEovV/WGd8rP8EAa3pYh5mxGLRVEE+HK7J01YaxLtZBYRRt588fVK79wSklP38x6wY1iQ==", + "version": "0.45.1", + "resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.45.1.tgz", + "integrity": "sha512-aoLsi0Mvd/46V5qz/CSdIle+tvHfRYsLsmNolraze469JLwzNXW1g1ZAAkEDayspwIroqd3QasU//GBgTrvDXg==", "requires": { "@babel/runtime": "7.16.0" } diff --git a/package.json b/package.json index 3cd957b52..2ab99c401 100755 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@babel/runtime": "7.16.0", "@sentry/browser": "6.13.3", "@stremio/stremio-colors": "5.0.1", - "@stremio/stremio-core-web": "0.45.0", + "@stremio/stremio-core-web": "0.45.1", "@stremio/stremio-icons": "5.0.0-beta.3", "@stremio/stremio-video": "0.0.26", "a-color-picker": "1.2.1", From 908e9d68301d807bb4363f087c964bbace16f8a5 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 4 Jan 2024 15:25:48 +0100 Subject: [PATCH 6/7] chore: update stremio-translations --- package-lock.json | 12 +++++++----- package.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 12ca92c87..58d6aca7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "react-i18next": "^12.1.1", "react-is": "18.2.0", "spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6", - "stremio-translations": "github:Stremio/stremio-translations#13c8241ca262541813ce0e2df4ff3e289fbd391b", + "stremio-translations": "github:Stremio/stremio-translations#12b1307f95249496960d2a257b371db5700721e6", "url": "0.11.0", "use-long-press": "^3.1.5" }, @@ -13600,8 +13600,9 @@ } }, "node_modules/stremio-translations": { - "version": "1.44.4", - "resolved": "git+ssh://git@github.com/Stremio/stremio-translations.git#13c8241ca262541813ce0e2df4ff3e289fbd391b", + "version": "1.44.5", + "resolved": "git+ssh://git@github.com/Stremio/stremio-translations.git#12b1307f95249496960d2a257b371db5700721e6", + "integrity": "sha512-929O9sIUph3ew4YlUfD/zoMUSAYmwrjRIS+opmft3Gi8qS36/gBrH8RYW8XvgkTon+xrgqr7hC2/QSck4tgrAA==", "license": "MIT" }, "node_modules/string_decoder": { @@ -26006,8 +26007,9 @@ "dev": true }, "stremio-translations": { - "version": "git+ssh://git@github.com/Stremio/stremio-translations.git#13c8241ca262541813ce0e2df4ff3e289fbd391b", - "from": "stremio-translations@github:Stremio/stremio-translations#13c8241ca262541813ce0e2df4ff3e289fbd391b" + "version": "git+ssh://git@github.com/Stremio/stremio-translations.git#12b1307f95249496960d2a257b371db5700721e6", + "integrity": "sha512-929O9sIUph3ew4YlUfD/zoMUSAYmwrjRIS+opmft3Gi8qS36/gBrH8RYW8XvgkTon+xrgqr7hC2/QSck4tgrAA==", + "from": "stremio-translations@github:Stremio/stremio-translations#12b1307f95249496960d2a257b371db5700721e6" }, "string_decoder": { "version": "1.1.1", diff --git a/package.json b/package.json index d4b310ada..7981466e8 100755 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "react-i18next": "^12.1.1", "react-is": "18.2.0", "spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6", - "stremio-translations": "github:Stremio/stremio-translations#13c8241ca262541813ce0e2df4ff3e289fbd391b", + "stremio-translations": "github:Stremio/stremio-translations#12b1307f95249496960d2a257b371db5700721e6", "url": "0.11.0", "use-long-press": "^3.1.5" }, From e4fd8b02af68e22a898cbea7b8da7aeb4d4b7dbc Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 4 Jan 2024 15:30:32 +0100 Subject: [PATCH 7/7] refactor(Settings): add translation strings for remote endpoint --- src/routes/Settings/Settings.js | 6 +++--- src/routes/Settings/useStreamingServerSettingsInputs.js | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/routes/Settings/Settings.js b/src/routes/Settings/Settings.js index da90b8eaf..c920e4ed5 100644 --- a/src/routes/Settings/Settings.js +++ b/src/routes/Settings/Settings.js @@ -126,7 +126,7 @@ const Settings = () => { navigator.clipboard.writeText(streamingServer.remoteUrl); toast.show({ type: 'success', - title: 'Successfully copied remote url to clipboard', + title: t('SETTINGS_REMOTE_URL_COPIED'), timeout: 2500, }); } @@ -558,11 +558,11 @@ const Settings = () => { streamingServerRemoteUrlInput.value !== null ?
-
Remote url
+
{t('SETTINGS_REMOTE_URL')}
{streamingServerRemoteUrlInput.value}
-
diff --git a/src/routes/Settings/useStreamingServerSettingsInputs.js b/src/routes/Settings/useStreamingServerSettingsInputs.js index 6955ced73..0b612083c 100644 --- a/src/routes/Settings/useStreamingServerSettingsInputs.js +++ b/src/routes/Settings/useStreamingServerSettingsInputs.js @@ -1,6 +1,7 @@ // Copyright (C) 2017-2023 Smart code 203358507 const React = require('react'); +const { useTranslation } = require('react-i18next'); const isEqual = require('lodash.isequal'); const { useServices } = require('stremio/services'); @@ -53,6 +54,7 @@ const TORRENT_PROFILES = { const useStreamingServerSettingsInputs = (streamingServer) => { const { core } = useServices(); + const { t } = useTranslation(); // TODO combine those useMemo in one const streamingServerRemoteUrlInput = React.useMemo(() => ({ @@ -67,7 +69,7 @@ const useStreamingServerSettingsInputs = (streamingServer) => { return { options: [ { - label: 'Disabled', + label: t('SETTINGS_DISABLED'), value: null, }, ...streamingServer.networkInfo.content.availableInterfaces.map((address) => ({