Browse Source

fix(ts): fix non-captured type errors

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
pull/14240/head
Maksim Sukharev 9 months ago
committed by backportbot[bot]
parent
commit
87b56e5523
  1. 3
      src/PublicShareSidebarTrigger.vue
  2. 6
      src/components/CallView/CallFailedDialog.vue
  3. 3
      src/components/ImportEmailsDialog.vue
  4. 13
      src/components/PollViewer/PollEditor.vue
  5. 2
      src/components/PollViewer/PollManager.vue
  6. 14
      src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue
  7. 2
      src/components/RightSidebar/SipSettings.vue
  8. 12
      src/services/EventBus.ts
  9. 15
      src/services/coreService.ts
  10. 9
      src/types/index.ts

3
src/PublicShareSidebarTrigger.vue

@ -15,7 +15,8 @@
</template>
<script setup lang="ts">
import { computed, UnwrapNestedRefs } from 'vue'
import { computed } from 'vue'
import type { UnwrapNestedRefs } from 'vue'
import MessageText from 'vue-material-design-icons/MessageText.vue'

6
src/components/CallView/CallFailedDialog.vue

@ -30,7 +30,7 @@ const STATUS_ERRORS = {
403: t('spreed', 'This conversation is read-only'),
404: t('spreed', 'Conversation not found or not joined'),
412: t('spreed', "Lobby is still active and you're not a moderator"),
}
} as const
const connectionFailed = computed(() => store.getters.connectionFailed(props.token))
const connectionFailedDialogId = `connection-failed-${props.token}`
const message = computed(() => {
@ -38,8 +38,8 @@ const message = computed(() => {
return ''
}
const statusCode = connectionFailed.value?.meta?.statuscode
if (STATUS_ERRORS[statusCode]) {
const statusCode: keyof typeof STATUS_ERRORS | undefined = connectionFailed.value.meta?.statuscode
if (statusCode && STATUS_ERRORS[statusCode]) {
return STATUS_ERRORS[statusCode]
}
if (connectionFailed.value?.data?.error) {

3
src/components/ImportEmailsDialog.vue

@ -17,6 +17,7 @@ import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import { importEmails } from '../services/participantsService.js'
import type { ApiErrorResponse } from '../types/index.ts'
const loading = ref(false)
const listImport = ref<HTMLInputElement | null>(null)
@ -80,7 +81,7 @@ async function testList(file: File) {
const response = await importEmails(props.token, file, true)
uploadResult.value = response.data.ocs.data
} catch (error) {
uploadResult.value = error?.response?.data?.ocs?.data
uploadResult.value = (error as ApiErrorResponse).response?.data?.ocs?.data ?? null
} finally {
loading.value = false
}

13
src/components/PollViewer/PollEditor.vue

@ -157,8 +157,8 @@ const store = useStore()
const pollsStore = usePollsStore()
const isOpenedFromDraft = ref(false)
const pollOption = ref(null)
const pollImport = ref(null)
const pollOption = ref<InstanceType<typeof NcTextField>[] | null>(null)
const pollImport = ref<HTMLInputElement | null>(null)
const pollForm = reactive<createPollParams>({
question: '',
@ -210,7 +210,7 @@ function deleteOption(index: number) {
function addOption() {
pollForm.options.push('')
nextTick(() => {
pollOption.value.at(-1).focus()
pollOption.value!.at(-1).focus()
})
}
@ -247,7 +247,7 @@ function fillPollEditorFromDraft(id: number | null, fromDrafts: boolean) {
* Call native input[type='file'] to import a file
*/
function triggerImport() {
pollImport.value.click()
pollImport.value!.click()
}
/**
@ -255,7 +255,8 @@ function triggerImport() {
* @param event import event
*/
function importPoll(event: Event) {
if (!(event.target as HTMLInputElement).files?.[0]) {
const file = (event.target as HTMLInputElement).files?.[0]
if (!file) {
return
}
@ -270,7 +271,7 @@ function importPoll(event: Event) {
}
}
reader.readAsText((event.target as HTMLInputElement).files[0])
reader.readAsText(file)
}
/**

2
src/components/PollViewer/PollManager.vue

@ -17,7 +17,7 @@ import type { Events } from '../../services/EventBus.ts'
const store = useStore()
const pollEditorRef = ref(null)
const pollEditorRef = ref<InstanceType<typeof PollEditor> | null>(null)
const showPollEditor = ref(false)
const showPollDraftHandler = ref(false)

14
src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue

@ -34,11 +34,12 @@ import { useStore } from '../../../composables/useStore.js'
import { ATTENDEE } from '../../../constants.js'
import { searchMessages } from '../../../services/coreService.ts'
import { EventBus } from '../../../services/EventBus.ts'
import {
import type {
CoreUnifiedSearchResultEntry,
UserFilterObject,
SearchMessagePayload,
UnifiedSearchResponse,
Participant,
} from '../../../types/index.ts'
import CancelableRequest from '../../../utils/cancelableRequest.js'
@ -49,7 +50,7 @@ const emit = defineEmits<{
(event: 'close'): void
}>()
const searchBox = ref(null)
const searchBox = ref<InstanceType<typeof SearchBox> | null>(null)
const isFocused = ref(false)
const searchResults = ref<(CoreUnifiedSearchResultEntry &
{
@ -79,7 +80,7 @@ const token = computed(() => store.getters.getToken())
const participantsInitialised = computed(() => store.getters.participantsInitialised(token.value))
const participants = computed<UserFilterObject>(() => {
return store.getters.participantsList(token.value)
.filter(({ actorType }) => actorType === ATTENDEE.ACTOR_TYPE.USERS) // FIXME: federated users are not supported by the search provider
.filter(({ actorType }: Participant) => actorType === ATTENDEE.ACTOR_TYPE.USERS) // FIXME: federated users are not supported by the search provider
.map(({ actorId, displayName, actorType }: { actorId: string; displayName: string; actorType: string}) => ({
id: actorId,
displayName,
@ -162,7 +163,7 @@ type SearchMessageCancelableRequest = {
* @param [isNew=true] Is it a new search (search parameters changed)?
* Fetch the search results from the server
*/
async function fetchSearchResults(isNew = true) {
async function fetchSearchResults(isNew = true): Promise<void> {
const term = searchText.value.trim()
// Don't search if the search text is empty
if (term.length === 0) {
@ -191,8 +192,9 @@ async function fetchSearchResults(isNew = true) {
const response = await request({
term,
person: fromUser.value?.id,
since: !isNaN(sinceDate.value) ? sinceDate.value?.toISOString() : null,
until: !isNaN(untilDate.value) ? untilDate.value?.toISOString() : null,
// FIXME: this might be invalid date. Remove after vue-lib bump: https://github.com/nextcloud-libraries/nextcloud-vue/pull/6387
since: sinceDate.value?.toISOString(),
until: untilDate.value?.toISOString(),
limit: searchLimit.value,
cursor: searchCursor.value || null,
from: `/call/${token.value}`,

2
src/components/RightSidebar/SipSettings.vue

@ -18,7 +18,7 @@ const props = defineProps<{
const dialInInfo = ref(t('spreed', 'Loading …'))
const meetingId = computed(() => readableNumber(props.conversation.token))
const attendeePin = computed(() => readableNumber(props.conversation.attendeePin))
const attendeePin = computed(() => readableNumber(props.conversation.attendeePin!))
onMounted(() => {
EventBus.on('signaling-settings-updated', setDialInInfoFromSettings)

12
src/services/EventBus.ts

@ -7,11 +7,12 @@ import mitt from 'mitt'
import type { Emitter, EventType, Handler, WildcardHandler } from 'mitt'
import type { Route } from 'vue-router'
import type { ChatMessage, Conversation, Participant } from '../types/index.ts'
import type { ChatMessage, Conversation, Participant, SignalingSettings } from '../types/index.ts'
import type { components } from '../types/openapi/openapi-full.ts'
// List of used events across the app
export type Events = Record<EventType, unknown> & {
export type Events = {
[key: EventType]: unknown,
'audio-player-ended': number,
'conversations-received': { singleConversation: boolean },
'deleted-session-detected': void,
@ -36,6 +37,7 @@ export type Events = Record<EventType, unknown> & {
'signaling-join-room': [string],
'signaling-participant-list-changed': void,
'signaling-recording-status-changed': [string, number],
'signaling-settings-updated': [SignalingSettings],
'signaling-users-changed': [(Partial<Participant> & ({ sessionId: string } | { nextcloudSessionId: string }))[]],
'signaling-users-in-room': [{ sessionId: string, userId: string }[]],
'smart-picker-open': void,
@ -49,8 +51,10 @@ export type Events = Record<EventType, unknown> & {
// Extended types for mitt() library
type GenericEventHandler = Handler<Events[keyof Events]> | WildcardHandler<Events>
type ExtendedEmitter = Emitter<Events> & {
once<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void
once(type: '*', handler: WildcardHandler<Events>): void
once: {
<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void
(type: '*', handler: WildcardHandler<Events>): void
}
_onceHandlers: Map<keyof Events | '*', Map<GenericEventHandler, GenericEventHandler>>
}

15
src/services/coreService.ts

@ -18,11 +18,12 @@ const canInviteToFederation = hasTalkFeature('local', 'federation-v1')
&& getTalkConfig('local', 'federation', 'enabled')
&& getTalkConfig('local', 'federation', 'outgoing-enabled')
type ShareType = typeof SHARE.TYPE[keyof typeof SHARE.TYPE]
type SearchPayload = {
searchText: string
token?: string | 'new'
onlyUsers?: boolean
forceTypes?: typeof SHARE.TYPE[keyof typeof SHARE.TYPE][]
forceTypes?: ShareType[]
}
/**
@ -36,15 +37,15 @@ type SearchPayload = {
* @param options options
*/
const autocompleteQuery = async function({ searchText, token = 'new', onlyUsers = false, forceTypes = [] }: SearchPayload, options: object) {
const shareTypes = onlyUsers
? [SHARE.TYPE.USER].concat(forceTypes)
const shareTypes: ShareType[] = onlyUsers
? [SHARE.TYPE.USER]
: [
SHARE.TYPE.USER,
SHARE.TYPE.GROUP,
SHARE.TYPE.CIRCLE,
token !== 'new' ? SHARE.TYPE.EMAIL : null,
canInviteToFederation ? SHARE.TYPE.REMOTE : null,
].filter(type => type !== null).concat(forceTypes)
...(token !== 'new' ? [SHARE.TYPE.EMAIL] : []),
...(canInviteToFederation ? [SHARE.TYPE.REMOTE] : []),
]
return axios.get(generateOcsUrl('core/autocomplete/get'), {
...options,
@ -52,7 +53,7 @@ const autocompleteQuery = async function({ searchText, token = 'new', onlyUsers
search: searchText,
itemType: 'call',
itemId: token,
shareTypes,
shareTypes: shareTypes.concat(forceTypes),
},
})
}

9
src/types/index.ts

@ -2,6 +2,8 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { AxiosError } from '@nextcloud/axios'
import type { components, operations } from './openapi/openapi-full.ts'
import { TASK_PROCESSING } from '../constants.js'
@ -19,6 +21,13 @@ type ApiResponseUnwrapped<T> = Promise<{
}
}>
export type ApiErrorResponse<T = null> = AxiosError<{
ocs: {
meta: components['schemas']['OCSMeta']
data: T
}
}>
type SpreedCapabilities = components['schemas']['Capabilities']
// From https://github.com/nextcloud/password_policy/blob/master/lib/Capabilities.php

Loading…
Cancel
Save