Merge pull request #330 from Stremio/feat/data-export

Feat/data export
This commit is contained in:
Alexandru Branza 2022-12-25 12:05:14 +02:00 committed by GitHub
commit d6736e84cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 10 deletions

14
package-lock.json generated
View file

@ -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.44.8",
"@stremio/stremio-core-web": "0.44.10",
"@stremio/stremio-icons": "4.0.0",
"@stremio/stremio-video": "0.0.24",
"a-color-picker": "1.2.1",
@ -2699,9 +2699,9 @@
"integrity": "sha512-Dt3PYmy1DZ473QNs99KYXVWQPHtpIl37VUY0+gCEvvuCqE1fRrZIJtZ9KbysUKonvO7WwdQDztgcW0iGoc1dEA=="
},
"node_modules/@stremio/stremio-core-web": {
"version": "0.44.8",
"resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.44.8.tgz",
"integrity": "sha512-c7ARfOxf0yy73b6sZauCLPUjpNYacF9tZXW7bxxg18IBGv7kXDBvLnk1rc54XKhJfHRgAPJuY5I1ijA0bM4nBQ==",
"version": "0.44.10",
"resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.44.10.tgz",
"integrity": "sha512-+AUJ3d5u5SH64lcuQIAtXPfeIaWzSNfdDL92HECXP29qat2TtCyM+ENLhTuMZzrbInD22SQrRhfIS3T8nFVQYg==",
"dependencies": {
"@babel/runtime": "7.16.0"
}
@ -16716,9 +16716,9 @@
"integrity": "sha512-Dt3PYmy1DZ473QNs99KYXVWQPHtpIl37VUY0+gCEvvuCqE1fRrZIJtZ9KbysUKonvO7WwdQDztgcW0iGoc1dEA=="
},
"@stremio/stremio-core-web": {
"version": "0.44.8",
"resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.44.8.tgz",
"integrity": "sha512-c7ARfOxf0yy73b6sZauCLPUjpNYacF9tZXW7bxxg18IBGv7kXDBvLnk1rc54XKhJfHRgAPJuY5I1ijA0bM4nBQ==",
"version": "0.44.10",
"resolved": "https://registry.npmjs.org/@stremio/stremio-core-web/-/stremio-core-web-0.44.10.tgz",
"integrity": "sha512-+AUJ3d5u5SH64lcuQIAtXPfeIaWzSNfdDL92HECXP29qat2TtCyM+ENLhTuMZzrbInD22SQrRhfIS3T8nFVQYg==",
"requires": {
"@babel/runtime": "7.16.0"
}

View file

@ -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.44.8",
"@stremio/stremio-core-web": "0.44.10",
"@stremio/stremio-icons": "4.0.0",
"@stremio/stremio-video": "0.0.24",
"a-color-picker": "1.2.1",

View file

@ -9,6 +9,7 @@ const { useServices } = require('stremio/services');
const { Button, Checkbox, MainNavBars, Multiselect, ColorInput, TextInput, ModalDialog, useProfile, useStreamingServer, useBinaryState, withCoreSuspender } = require('stremio/common');
const useProfileSettingsInputs = require('./useProfileSettingsInputs');
const useStreamingServerSettingsInputs = require('./useStreamingServerSettingsInputs');
const useDataExport = require('./useDataExport');
const styles = require('./styles');
const GENERAL_SECTION = 'general';
@ -20,6 +21,7 @@ const Settings = () => {
const { core } = useServices();
const { routeFocused } = useRouteFocused();
const profile = useProfile();
const [dataExport, loadDataExport] = useDataExport();
const streamingServer = useStreamingServer();
const {
interfaceLanguageSelect,
@ -82,7 +84,7 @@ const Settings = () => {
// TODO
}, []);
const exportDataOnClick = React.useCallback(() => {
// TODO
loadDataExport();
}, []);
const reloadStreamingServer = React.useCallback(() => {
core.transport.dispatch({
@ -128,6 +130,11 @@ const Settings = () => {
const sectionsContainerOnScorll = React.useCallback(throttle(() => {
updateSelectedSectionId();
}, 50), []);
React.useEffect(() => {
if (dataExport.exportUrl !== null && typeof dataExport.exportUrl === 'string') {
window.open(dataExport.exportUrl);
}
}, [dataExport.exportUrl]);
React.useLayoutEffect(() => {
if (routeFocused) {
updateSelectedSectionId();
@ -240,7 +247,7 @@ const Settings = () => {
</Button>
</div>
<div className={styles['option-container']}>
<Button className={classnames(styles['option-input-container'], styles['link-container'])} title={'Export user data'} disabled={true} tabIndex={-1} onClick={exportDataOnClick}>
<Button className={classnames(styles['option-input-container'], styles['link-container'])} title={'Export user data'} tabIndex={-1} onClick={exportDataOnClick}>
<div className={styles['label']}>Export user data</div>
</Button>
</div>

View file

@ -0,0 +1,32 @@
// Copyright (C) 2017-2022 Smart code 203358507
const React = require('react');
const { useServices } = require('stremio/services');
const { useModelState } = require('stremio/common');
const map = (dataExport) => ({
...dataExport,
exportUrl: dataExport !== null && dataExport.exportUrl !== null && dataExport.exportUrl.type === 'Ready' ?
dataExport.exportUrl.content
:
null
});
const useDataExport = () => {
const { core } = useServices();
const loadDataExport = React.useCallback(() => {
core.transport.dispatch({
action: 'Load',
args: {
model: 'DataExport',
}
}, 'data_export');
}, []);
const dataExport = useModelState({ model: 'data_export', map });
return [
dataExport,
loadDataExport
];
};
module.exports = useDataExport;