Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Files sidebar tab to changes in server #4291

Merged
merged 3 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/mainFilesSidebarLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

import FilesSidebarCallView from './views/FilesSidebarCallView'
import FilesSidebarTab from './views/FilesSidebarTab'
import { leaveConversation } from './services/participantsService'

const isEnabled = function(fileInfo) {
Expand All @@ -46,9 +45,45 @@ const isEnabled = function(fileInfo) {
return false
}

// It might be enough to keep the instance only in the Tab object itself,
// without using a shared variable that can be destroyed if a new tab is
// mounted and the previous one was not destroyed yet, as the tabs seem to
// always be properly destroyed. However, this is how it is done for tabs in
// server, so it is done here too just to be safe.
let tabInstance = null

window.addEventListener('DOMContentLoaded', () => {
if (OCA.Files && OCA.Files.Sidebar) {
OCA.Files.Sidebar.registerSecondaryView(new FilesSidebarCallView())
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab('tab-chat', FilesSidebarTab, isEnabled))
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab({
id: 'chat',
name: t('spreed', 'Chat'),
icon: 'icon-talk',
enabled: isEnabled,

async mount(el, fileInfo, context) {
if (tabInstance) {
tabInstance.$destroy()
}

// Dirty hack to force the style on parent component
const tabChat = document.querySelector('#tab-chat')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no proper way ? can we instead set a class on the parent that we can style from here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken there have been some changes in the Files app sidebar related to this, I would need to check again.

tabChat.style.height = '100%'
// Remove paddding to maximize space for the chat view
tabChat.style.padding = '0'

OCA.Talk.fileInfo = this.fileInfo
tabInstance = OCA.Talk.newTab()
tabInstance.$mount(el)
},
update(fileInfo) {
OCA.Talk.fileInfo = fileInfo
},
destroy() {
OCA.Talk.fileInfo = null
tabInstance.$destroy()
tabInstance = null
},
}))
}
})
111 changes: 0 additions & 111 deletions src/views/FilesSidebarTab.vue

This file was deleted.