Skip to content
Snippets Groups Projects
Commit de26eb39 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor: move useSelectedShow helper function for better TS DX

parent 78ec46fb
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,8 @@ import { cloneDeep, isEqual } from 'lodash'
import { computed, ComputedGetter, ComputedRef, readonly, Ref, ref, watch, watchEffect } from 'vue'
import { formatISO, parseISO } from 'date-fns'
import DOMPurify from 'dompurify'
import { useStore } from 'vuex'
import { Show } from '@/types'
export function computedIter<T>(fn: ComputedGetter<Iterable<T>>): ComputedRef<T[]> {
return computed(() => Array.from(fn()))
......@@ -120,3 +122,15 @@ export function sanitizeHTML(
return DOMPurify.sanitize(html, { ALLOWED_TAGS: [] })
}
export function useSelectedShow() {
const store = useStore()
return computed<Show>({
get() {
return store.state.shows.shows[store.state.shows.selected.index]
},
set(show) {
store.commit('shows/switchShowById', show.id)
},
})
}
import { useStore } from 'vuex'
import { computed } from 'vue'
export { useSelectedShow } from './util'
export function uppercaseFirst(string = '') {
return string.charAt(0).toUpperCase() + string.slice(1)
......@@ -33,17 +32,6 @@ export function getTimeString(date, withSeconds = false) {
return `${hours}:${minutes}${withSeconds ? `:${seconds}` : ''}`
}
export function useSelectedShow() {
const store = useStore()
return computed({
get() {
return store.state.shows.shows[store.state.shows.selected.index]
},
set(show) {
store.commit('shows/switchShowById', show.id)
},
})
}
export function shouldLog(message, instance, trace) {
// don’t log any Bootstrap-Vue warnings
if (/^B[A-Z]/.test(instance?.$options?.name ?? '')) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment