mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 14:52:13 +00:00
feat(Settings): implement data export
This commit is contained in:
parent
52fdee39e7
commit
9433897b05
2 changed files with 31 additions and 3 deletions
|
|
@ -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 = useDataExport();
|
||||
const streamingServer = useStreamingServer();
|
||||
const {
|
||||
interfaceLanguageSelect,
|
||||
|
|
@ -82,8 +84,10 @@ const Settings = () => {
|
|||
// TODO
|
||||
}, []);
|
||||
const exportDataOnClick = React.useCallback(() => {
|
||||
// TODO
|
||||
}, []);
|
||||
if (dataExport.exportUrl !== null && typeof dataExport.exportUrl === 'string') {
|
||||
window.open(dataExport.exportUrl);
|
||||
}
|
||||
}, [dataExport.exportUrl]);
|
||||
const reloadStreamingServer = React.useCallback(() => {
|
||||
core.transport.dispatch({
|
||||
action: 'StreamingServer',
|
||||
|
|
@ -240,7 +244,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'} disabled={dataExport.exportUrl === null} tabIndex={-1} onClick={exportDataOnClick}>
|
||||
<div className={styles['label']}>Export user data</div>
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
24
src/routes/Settings/useDataExport.js
Normal file
24
src/routes/Settings/useDataExport.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2017-2022 Smart code 203358507
|
||||
|
||||
const React = require('react');
|
||||
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 action = React.useMemo(() => ({
|
||||
action: 'Load',
|
||||
args: {
|
||||
model: 'DataExport',
|
||||
}
|
||||
}), []);
|
||||
return useModelState({ model: 'data_export', action, map });
|
||||
};
|
||||
|
||||
module.exports = useDataExport;
|
||||
Loading…
Reference in a new issue