mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-02 22:44:24 +00:00
useSettings hook
This commit is contained in:
parent
90568c9e85
commit
3dac8f96f3
2 changed files with 25 additions and 25 deletions
|
|
@ -4,30 +4,10 @@ const styles = require('./styles');
|
||||||
const SectionsSelector = require('./SectionsSelector');
|
const SectionsSelector = require('./SectionsSelector');
|
||||||
const SectionsList = require('./SectionsList');
|
const SectionsList = require('./SectionsList');
|
||||||
const { settingsSections } = require('./constants');
|
const { settingsSections } = require('./constants');
|
||||||
|
const settingsValues = require('./useSettings');
|
||||||
|
|
||||||
const devTestWithUser = true;
|
const devTestWithUser = true;
|
||||||
|
|
||||||
const settingsValues = {
|
|
||||||
"user": devTestWithUser ? {
|
|
||||||
"_id": "neo",
|
|
||||||
"email": "neo@example.com",
|
|
||||||
"avatar": "https://www.thenational.ae/image/policy:1.891803:1566372420/AC17-Matrix-20-04.jpg?f=16x9&w=1200&$p$f$w=5867e40",
|
|
||||||
} : null,
|
|
||||||
"ui_language": "eng",
|
|
||||||
"default_subtitles_language": "bul",
|
|
||||||
"default_subtitles_size": "100%",
|
|
||||||
"subtitles_background": "",
|
|
||||||
"subtitles_color": "#ffffff",
|
|
||||||
"subtitles_outline_color": "#000",
|
|
||||||
"auto-play_next_episode": true,
|
|
||||||
"pause_playback_when_minimized": false,
|
|
||||||
"hardware-accelerated_decoding": true,
|
|
||||||
"launch_player_in_a_separate_window_(advanced)": true,
|
|
||||||
"caching": "2048",
|
|
||||||
"torrent_profile": "profile-default",
|
|
||||||
"streaming_server_is_available.": true,
|
|
||||||
};
|
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
const sections = Object.keys(settingsSections)
|
const sections = Object.keys(settingsSections)
|
||||||
.map((section) => ({
|
.map((section) => ({
|
||||||
|
|
@ -36,15 +16,13 @@ const Settings = () => {
|
||||||
ref: React.useRef(null)
|
ref: React.useRef(null)
|
||||||
}));
|
}));
|
||||||
const [selectedSectionId, setSelectedSectionId] = React.useState(sections[0].id);
|
const [selectedSectionId, setSelectedSectionId] = React.useState(sections[0].id);
|
||||||
const [preferences, setPreferences] = React.useState(settingsValues);
|
const [preferences, setPreferences] = settingsValues(devTestWithUser);
|
||||||
const scrollContainerRef = React.useRef(null);
|
const scrollContainerRef = React.useRef(null);
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|
||||||
const updatePreference = (option, value) => {
|
const updatePreference = (option, value) => {
|
||||||
const newPrefs = { ...preferences };
|
setPreferences({ ...preferences, [option]: value });
|
||||||
newPrefs[option] = value;
|
|
||||||
setPreferences(newPrefs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeSection = React.useCallback((event) => {
|
const changeSection = React.useCallback((event) => {
|
||||||
|
|
|
||||||
22
src/routes/Settings/useSettings.js
Normal file
22
src/routes/Settings/useSettings.js
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
const React = require('react');
|
||||||
|
|
||||||
|
module.exports = (devTestWithUser) => React.useState({
|
||||||
|
"user": devTestWithUser ? {
|
||||||
|
"_id": "neo",
|
||||||
|
"email": "neo@example.com",
|
||||||
|
"avatar": "https://www.thenational.ae/image/policy:1.891803:1566372420/AC17-Matrix-20-04.jpg?f=16x9&w=1200&$p$f$w=5867e40",
|
||||||
|
} : null,
|
||||||
|
"ui_language": "eng",
|
||||||
|
"default_subtitles_language": "bul",
|
||||||
|
"default_subtitles_size": "100%",
|
||||||
|
"subtitles_background": "",
|
||||||
|
"subtitles_color": "#ffffff",
|
||||||
|
"subtitles_outline_color": "#000",
|
||||||
|
"auto-play_next_episode": true,
|
||||||
|
"pause_playback_when_minimized": false,
|
||||||
|
"hardware-accelerated_decoding": true,
|
||||||
|
"launch_player_in_a_separate_window_(advanced)": true,
|
||||||
|
"caching": "2048",
|
||||||
|
"torrent_profile": "profile-default",
|
||||||
|
"streaming_server_is_available.": true,
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue