Skip to content

Commit 408c061

Browse files
committed
handle all 'joined-conversation' events
Signed-off-by: Maksim Sukharev <[email protected]>
1 parent 744f077 commit 408c061

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/components/LeftSidebar/LeftSidebar.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,9 @@ describe('LeftSidebar.vue', () => {
663663
expect(resultsListItems).toHaveLength(resultsList.length)
664664

665665
await resultsListItems.at(0).findAll('a').trigger('click')
666+
// FIXME Real router and store should work at this place to execute following:
667+
// click => route-change => participantsStore.joinConversation() => joined-conversation
668+
EventBus.$emit('joined-conversation', { token: 'new-conversation' })
666669
await flushPromises()
667670

668671
expect(searchBoxEl.exists()).toBeTruthy()

src/components/LeftSidebar/LeftSidebar.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ export default {
285285
EventBus.$on('should-refresh-conversations', this.handleShouldRefreshConversations)
286286
EventBus.$once('conversations-received', this.handleUnreadMention)
287287
EventBus.$on('route-change', this.onRouteChange)
288-
EventBus.$once('joined-conversation', ({ token }) => {
289-
this.scrollToConversation(token)
290-
})
288+
EventBus.$on('joined-conversation', this.handleJoinedConversation)
291289
this.mountArrowNavigation()
292290
},
293291
@@ -406,10 +404,6 @@ export default {
406404
if (item.source === 'users') {
407405
// Create one-to-one conversation directly
408406
const conversation = await this.$store.dispatch('createOneToOneConversation', item.id)
409-
this.abortSearch()
410-
EventBus.$once('joined-conversation', ({ token }) => {
411-
this.scrollToConversation(token)
412-
})
413407
this.$router.push({
414408
name: 'conversation',
415409
params: { token: conversation.token },
@@ -586,6 +580,16 @@ export default {
586580
}
587581
},
588582
583+
handleJoinedConversation({ token }) {
584+
this.abortSearch()
585+
this.scrollToConversation(token)
586+
if (this.isMobile) {
587+
emit('toggle-navigation', {
588+
open: false,
589+
})
590+
}
591+
},
592+
589593
iconData(item) {
590594
if (item.source === 'users') {
591595
return {

0 commit comments

Comments
 (0)