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 <[email protected]>
  • Loading branch information
PVince81 committed Feb 12, 2021
1 parent fa55c6c commit ab45b79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 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,11 @@ 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
if (!window.OCA.Talk) {
window.OCA.Talk = {}
}
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 ab45b79

Please sign in to comment.