Skip to content

Commit

Permalink
Remove current room from RoomSelector
Browse files Browse the repository at this point in the history
Expose the Talk Vue instance on OCA.Talk.instance.
In RoomSelector, grab the current room from that instance to filter it
out, when applicableRemove current room from RoomSelector

Expose the Talk Vue instance on OCA.Talk.instance.
In RoomSelector, grab the current room from that instance to filter it
out, when applicable.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
  • Loading branch information
PVince81 committed Feb 12, 2021
1 parent 023bc23 commit c2c1fc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Vue.use(VueObserveVisibility)
Vue.use(VueShortKey, { prevent: ['input', 'textarea', 'div'] })
Vue.use(vOutsideEvents)

export default new Vue({
const instance = new Vue({
el: '#content',
store,
router,
Expand Down Expand Up @@ -155,3 +155,8 @@ Sidebar.prototype.close = function() {
Object.assign(window.OCA.Files, {
Sidebar: new Sidebar(),
})

// make the instance available to global components that might run on the same page
OCA.Talk.instance = instance

export default instance
7 changes: 7 additions & 0 deletions src/views/RoomSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ export default {
return {
rooms: [],
selectedRoom: null,
currentRoom: null,
loading: true,
}
},
computed: {
availableRooms() {
return this.rooms.filter((room) => {
return room.type !== CONVERSATION.TYPE.CHANGELOG
&& (!this.currentRoom || this.currentRoom !== room.token)
&& (!this.showPostableOnly || room.readOnly === CONVERSATION.STATE.READ_WRITE)
&& room.objectType !== 'file'
&& room.objectType !== 'share:password'
Expand All @@ -102,6 +104,11 @@ export default {
},
beforeMount() {
this.fetchRooms()
const $store = OCA.Talk?.instance?.$store
if ($store) {
this.currentRoom = $store.getters.getToken()
}
},
methods: {
fetchRooms() {
Expand Down

0 comments on commit c2c1fc1

Please sign in to comment.