diff --git a/src/mainFilesSidebarLoader.js b/src/mainFilesSidebarLoader.js
index 55b32413111..efb70046788 100644
--- a/src/mainFilesSidebarLoader.js
+++ b/src/mainFilesSidebarLoader.js
@@ -21,7 +21,6 @@
*/
import FilesSidebarCallView from './views/FilesSidebarCallView'
-import FilesSidebarTab from './views/FilesSidebarTab'
import { leaveConversation } from './services/participantsService'
const isEnabled = function(fileInfo) {
@@ -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')
+ 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
+ },
+ }))
}
})
diff --git a/src/views/FilesSidebarTab.vue b/src/views/FilesSidebarTab.vue
deleted file mode 100644
index bc9ec599021..00000000000
--- a/src/views/FilesSidebarTab.vue
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-