Skip to content

Commit

Permalink
React to sidebar events
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed May 26, 2021
1 parent 7be9f86 commit b061a2e
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 27 deletions.
136 changes: 110 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@nextcloud/auth": "^1.3.0",
"@nextcloud/axios": "^1.6.0",
"@nextcloud/dialogs": "^3.1.1",
"@nextcloud/event-bus": "^2.0.0",
"@nextcloud/paths": "^1.1.2",
"@nextcloud/router": "^1.2.0",
"@nextcloud/vue": "^3.9.0",
Expand Down
14 changes: 13 additions & 1 deletion src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ import Vue from 'vue'
import axios from '@nextcloud/axios'
import '@nextcloud/dialogs/styles/toast.scss'
import { showError } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'

import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionLink from '@nextcloud/vue/dist/Components/ActionLink'
Expand Down Expand Up @@ -344,10 +345,22 @@ export default {
}
},

mount() {
// React to Files' Sidebar events.
subscribe('files:sidebar:opened', showAppsSidebar)
subscribe('files:sidebar:closed', hideAppsSidebar)
},

beforeDestroy() {
window.removeEventListener('resize', this.onResize)
},

destroy() {
// Unsubscribe to Files' Sidebar events.
unsubscribe('files:sidebar:opened', showAppsSidebar)
unsubscribe('files:sidebar:closed', hideAppsSidebar)
},

methods: {
/**
* Open the view and display the clicked file
Expand Down Expand Up @@ -723,7 +736,6 @@ export default {
// Open the sidebar sharing tab
// TODO: also hide figure, needs a proper method for it in server Sidebar
await OCA.Files.Sidebar.open(this.currentFile.filename)
setTimeout(this.showAppsSidebar, 100) // we have to wait the animation of the sidebar
},

showAppsSidebar() {
Expand Down

0 comments on commit b061a2e

Please sign in to comment.