fix: some typechecks
Most of what's still left now is related to models not exporting visible properties for typescript, that's a problem for another day.
This commit is contained in:
parent
654f5f8f57
commit
26a94c7e8c
7 changed files with 24 additions and 17 deletions
|
@ -42,7 +42,7 @@ import {useBodyClass} from '@/composables/useBodyClass'
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
useBodyClass('is-touch', isTouchDevice)
|
useBodyClass('is-touch', isTouchDevice())
|
||||||
const keyboardShortcutsActive = computed(() => store.state.keyboardShortcutsActive)
|
const keyboardShortcutsActive = computed(() => store.state.keyboardShortcutsActive)
|
||||||
|
|
||||||
const authUser = computed(() => store.getters['auth/authUser'])
|
const authUser = computed(() => store.getters['auth/authUser'])
|
||||||
|
|
|
@ -28,19 +28,20 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {ref, watch} from 'vue'
|
import {PropType, ref, watch} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useStore} from 'vuex'
|
||||||
|
|
||||||
import ListService from '@/services/list'
|
import ListService from '@/services/list'
|
||||||
|
|
||||||
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
import {colorIsDark} from '@/helpers/color/colorIsDark'
|
||||||
|
import ListModel from '@/models/list'
|
||||||
|
|
||||||
const background = ref<string | null>(null)
|
const background = ref<string | null>(null)
|
||||||
const backgroundLoading = ref(false)
|
const backgroundLoading = ref(false)
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
list: {
|
list: {
|
||||||
type: Object,
|
type: Object as PropType<ListModel>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
showArchived: {
|
showArchived: {
|
||||||
|
@ -68,7 +69,7 @@ async function loadBackground() {
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
function toggleFavoriteList(list) {
|
function toggleFavoriteList(list: ListModel) {
|
||||||
// The favorites pseudo list is always favorite
|
// The favorites pseudo list is always favorite
|
||||||
// Archived lists cannot be marked favorite
|
// Archived lists cannot be marked favorite
|
||||||
if (list.id === -1 || list.isArchived) {
|
if (list.id === -1 || list.isArchived) {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, shallowRef} from 'vue'
|
import {computed, PropType, shallowRef} from 'vue'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import SubscriptionService from '@/services/subscription'
|
import SubscriptionService from '@/services/subscription'
|
||||||
|
@ -38,9 +38,11 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
subscription: {
|
subscription: {
|
||||||
required: true,
|
required: true,
|
||||||
|
type: Object as PropType<SubscriptionModel>,
|
||||||
},
|
},
|
||||||
entityId: {
|
entityId: {
|
||||||
required: true,
|
required: true,
|
||||||
|
type: Number,
|
||||||
},
|
},
|
||||||
isButton: {
|
isButton: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -48,6 +50,8 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const subscriptionEntity = computed<string>(() => props.subscription.entity)
|
||||||
|
|
||||||
const emit = defineEmits(['change'])
|
const emit = defineEmits(['change'])
|
||||||
|
|
||||||
const subscriptionService = shallowRef(new SubscriptionService())
|
const subscriptionService = shallowRef(new SubscriptionService())
|
||||||
|
@ -57,7 +61,7 @@ const tooltipText = computed(() => {
|
||||||
if (disabled.value) {
|
if (disabled.value) {
|
||||||
return t('task.subscription.subscribedThroughParent', {
|
return t('task.subscription.subscribedThroughParent', {
|
||||||
entity: props.entity,
|
entity: props.entity,
|
||||||
parent: props.subscription.entity,
|
parent: subscriptionEntity.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +77,7 @@ const disabled = computed(() => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.subscription.entity !== props.entity
|
return subscriptionEntity.value !== props.entity
|
||||||
})
|
})
|
||||||
|
|
||||||
function changeSubscription() {
|
function changeSubscription() {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
import {ref, computed} from 'vue'
|
import {ref, computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useStore} from 'vuex'
|
||||||
import Multiselect from '@/components/input/multiselect.vue'
|
import Multiselect from '@/components/input/multiselect.vue'
|
||||||
|
import NamespaceModel from '@/models/namespace'
|
||||||
|
|
||||||
const emit = defineEmits(['selected'])
|
const emit = defineEmits(['selected'])
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ function findNamespaces(newQuery: string) {
|
||||||
query.value = newQuery
|
query.value = newQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
function select(namespace) {
|
function select(namespace: NamespaceModel) {
|
||||||
emit('selected', namespace)
|
emit('selected', namespace)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {computed, watch, readonly} from 'vue'
|
import {computed, watch, readonly} from 'vue'
|
||||||
import {useStorage, createSharedComposable, ColorSchema, usePreferredColorScheme, tryOnMounted} from '@vueuse/core'
|
import {useStorage, createSharedComposable, BasicColorSchema, usePreferredColorScheme, tryOnMounted} from '@vueuse/core'
|
||||||
|
|
||||||
const STORAGE_KEY = 'color-scheme'
|
const STORAGE_KEY = 'color-scheme'
|
||||||
|
|
||||||
const DEFAULT_COLOR_SCHEME_SETTING: ColorSchema = 'light'
|
const DEFAULT_COLOR_SCHEME_SETTING: BasicColorSchema = 'light'
|
||||||
|
|
||||||
const CLASS_DARK = 'dark'
|
const CLASS_DARK = 'dark'
|
||||||
const CLASS_LIGHT = 'light'
|
const CLASS_LIGHT = 'light'
|
||||||
|
@ -16,7 +16,7 @@ const CLASS_LIGHT = 'light'
|
||||||
// - value is synced via `createSharedComposable`
|
// - value is synced via `createSharedComposable`
|
||||||
// https://github.com/vueuse/vueuse/blob/main/packages/core/useDark/index.ts
|
// https://github.com/vueuse/vueuse/blob/main/packages/core/useDark/index.ts
|
||||||
export const useColorScheme = createSharedComposable(() => {
|
export const useColorScheme = createSharedComposable(() => {
|
||||||
const store = useStorage<ColorSchema>(STORAGE_KEY, DEFAULT_COLOR_SCHEME_SETTING)
|
const store = useStorage<BasicColorSchema>(STORAGE_KEY, DEFAULT_COLOR_SCHEME_SETTING)
|
||||||
|
|
||||||
const preferredColorScheme = usePreferredColorScheme()
|
const preferredColorScheme = usePreferredColorScheme()
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ app.use(Notifications)
|
||||||
|
|
||||||
// directives
|
// directives
|
||||||
import focus from '@/directives/focus'
|
import focus from '@/directives/focus'
|
||||||
|
// @ts-ignore The export does exist, ts just doesn't find it.
|
||||||
import { VTooltip } from 'v-tooltip'
|
import { VTooltip } from 'v-tooltip'
|
||||||
import 'v-tooltip/dist/v-tooltip.css'
|
import 'v-tooltip/dist/v-tooltip.css'
|
||||||
import shortcut from '@/directives/shortcut'
|
import shortcut from '@/directives/shortcut'
|
||||||
|
|
|
@ -44,7 +44,7 @@ import Message from '@/components/misc/message.vue'
|
||||||
const {t} = useI18n()
|
const {t} = useI18n()
|
||||||
useTitle(t('sharing.authenticating'))
|
useTitle(t('sharing.authenticating'))
|
||||||
|
|
||||||
async function useAuth() {
|
function useAuth() {
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
@ -75,21 +75,21 @@ async function useAuth() {
|
||||||
password: password.value,
|
password: password.value,
|
||||||
})
|
})
|
||||||
router.push({name: 'list.list', params: {listId}})
|
router.push({name: 'list.list', params: {listId}})
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
if (e.response?.data?.code === 13001) {
|
if (e.response?.data?.code === 13001) {
|
||||||
authenticateWithPassword.value = true
|
authenticateWithPassword.value = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Put this logic in a global errorMessage handler method which checks all auth codes
|
// TODO: Put this logic in a global errorMessage handler method which checks all auth codes
|
||||||
let errorMessage = t('sharing.error')
|
let err = t('sharing.error')
|
||||||
if (e.response?.data?.message) {
|
if (e.response?.data?.message) {
|
||||||
errorMessage = e.response.data.message
|
err = e.response.data.message
|
||||||
}
|
}
|
||||||
if (e.response?.data?.code === 13002) {
|
if (e.response?.data?.code === 13002) {
|
||||||
errorMessage = t('sharing.invalidPassword')
|
err = t('sharing.invalidPassword')
|
||||||
}
|
}
|
||||||
errorMessage.value = errorMessage
|
errorMessage.value = err
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue