traxxx/assets/js/ui/state.js

46 lines
1010 B
JavaScript
Raw Normal View History

2021-01-03 21:53:51 +00:00
const storedTagFilter = localStorage.getItem('tagFilter');
const storedSummaryFormat = localStorage.getItem('summaryFormat');
const storedBatch = localStorage.getItem('batch');
2020-03-23 00:43:49 +00:00
const storedSfw = localStorage.getItem('sfw');
const storedTheme = localStorage.getItem('theme');
const deviceTheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
const defaultSummaryFormat = [
{
delimiter: ' - ',
segments: [
{
prop: 'channel',
},
{
prop: 'title',
},
],
},
{
delimiter: ', ',
bracket: '()',
segments: [
{
prop: 'actors',
delimiter: ', ',
},
{
prop: 'date',
format: 'DD-MM-YYYY',
},
],
},
];
export default {
2021-01-03 21:53:51 +00:00
tagFilter: storedTagFilter ? storedTagFilter.split(',') : [],
summaryFormat: storedSummaryFormat ? JSON.parse(storedSummaryFormat) : defaultSummaryFormat,
defaultSummaryFormat,
range: 'latest',
batch: storedBatch || 'all',
sfw: storedSfw === 'true' || false,
theme: storedTheme || deviceTheme,
};