Skip to content

Commit

Permalink
all filter preferences except for cast selection are session persisted
Browse files Browse the repository at this point in the history
  • Loading branch information
AltriusRS committed Sep 3, 2023
1 parent 771816b commit 7402873
Showing 1 changed file with 45 additions and 28 deletions.
73 changes: 45 additions & 28 deletions components/VideoFeed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ const orderOptions = ref([
label: 'Topic Count (Descending)'
}
])
const filters = useState('filter', () => {
return {
order: orderOptions.value[1],
hideCW: false,
hideCorrupt: false,
startDate: new Date('2012-08-28T00:00:00.000Z').toDateString(),
endDate: new Date().toDateString(),
members: []
}
})
const { data } = useAsyncData(async () => {
try {
Expand All @@ -55,21 +65,23 @@ const { data } = useAsyncData(async () => {
method: 'POST'
})).json()
cst.value = cast.data.map((m) => {
csm.value.set(m.id, {
id: m.id,
label: `${m.name} ${m.outlet ? ' (' + m.outlet + ')' : ''}`,
mug: `https://cdn.thewandb.com/mugs/${m.mug}`
})
if (filters.value.members.length === 0) {
cst.value = cast.data.map((m) => {
csm.value.set(m.id, {
id: m.id,
label: `${m.name} ${m.outlet ? ' (' + m.outlet + ')' : ''}`,
mug: `https://cdn.thewandb.com/mugs/${m.mug}`
})
return {
id: m.id,
label: `${m.name} ${m.outlet ? ' (' + m.outlet + ')' : ''}`,
avatar: {
src: `https://cdn.thewandb.com/mugs/${m.mug}`
return {
id: m.id,
label: `${m.name} ${m.outlet ? ' (' + m.outlet + ')' : ''}`,
avatar: {
src: `https://cdn.thewandb.com/mugs/${m.mug}`
}
}
}
})
})
}
xsm.value = cast.data
}
Expand All @@ -83,34 +95,39 @@ const { data } = useAsyncData(async () => {
}
})
const filters = useState('filter', () => {
return {
order: {
id: 'release-desc',
label: 'Stream Date (Descending)'
},
hideCW: false,
hideCorrupt: false,
startDate: new Date('2012-08-28T00:00:00.000Z').toDateString(),
endDate: new Date().toDateString(),
members: []
let offset = 0
onMounted(() => {
try {
const raw = window.sessionStorage.getItem('FLTR')
if (raw) {
const fltr = JSON.parse(raw)
fltr.members = []
filters.value = fltr
} else {
window.sessionStorage.setItem('FLTR', JSON.stringify(filters.value))
}
} catch (e) {
console.error(e)
}
})
let offset = 0
function filter () {
offset = 0
fd.value = []
fdm.value = new Map()
try {
window.sessionStorage.setItem('FLTR', JSON.stringify(filters.value))
} catch (e) {
console.error(e)
}
infinite()
}
async function infinite () {
loading.value = true
try {
const f = filters.value
console.log(f)
const f = JSON.parse(JSON.stringify(filters.value))
f.members = f.members.map(m => m.id)
const feed = await (await fetcher(config.public.api_base + '/episodes', {
Expand Down

0 comments on commit 7402873

Please sign in to comment.