Skip to content

Commit 8a2b4ab

Browse files
committed
refactor: simplify typing with as
1 parent 7e01407 commit 8a2b4ab

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/components/Chat/Chats.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,8 @@ const noMoreChats = ref(false)
135135
const loadingSeparator = ref<InstanceType<typeof ChatPreview>[]>([])
136136
137137
const chatPagePartnerId = computed(() => {
138-
const partnerId = route.params.partnerId
139-
140-
// To convert it to string immediately => no need in further type conversion
141-
return Array.isArray(partnerId) ? partnerId[0] : partnerId
138+
// We assume partnerId to always be a string
139+
return route.params.partnerId as string
142140
})
143141
const isSnackbarShowing = computed(() => store.state.snackbar.show)
144142
const noActiveNodesDialog = computed(() => store.state.chat.noActiveNodesDialog)
@@ -218,12 +216,13 @@ const checkIsActive = (contactId: string) => {
218216
const onKeydownHandler = (e: KeyboardEvent) => {
219217
if (canPressEscape.value) {
220218
if (e.key === 'Escape') {
221-
if (!route.query.from) {
222-
return router.push({ name: 'Chats' })
219+
if (route.query.from?.includes('chats')) {
220+
router.push(route.query.from as string)
221+
return
223222
}
224-
225-
const from = Array.isArray(route.query.from) ? route.query.from[0] : route.query.from
226-
return from ? router.push(from) : router.push({ name: 'Chats' })
223+
router.push({
224+
name: 'Chats'
225+
})
227226
}
228227
}
229228
}

0 commit comments

Comments
 (0)