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 authored and backportbot[bot] committed Feb 15, 2021
1 parent 376fd64 commit ee5cb92
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 @@ -70,7 +70,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 @@ -154,3 +154,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 ee5cb92

Please sign in to comment.