Skip to content

Commit 058dd55

Browse files
committed
fix(files): Do not fail on missing sidebar in files list
When using richdocuments it was failing in case of shared links or when user with opened file did a wheel click on a refresh page. Then new tab appeared but instead opening the file it was doing nothing (showing the list of files) or downloading the file. Make code more defensive. I found these logs while debugging: OCA.Files.Settings initialized Sidebar.js:19 OCA.Files.Sidebar initialized ShareSearch.js:16 OCA.Sharing.ShareSearch initialized comments-app.js:15 OCA.Comments.View initialized index.mjs:54 files: Error while opening sidebar Object log @ index.mjs:54 index.mjs:54 files: Error while opening sidebar Objectapp: "files" TypeError: window.OCA.Files.Sidebar.open is not a function at h.exec (http://nc/dist/files-main.js?v=106d16db-0:1:70123) at o.openSidebarForFile (http://nc/dist/files-main.js?v=106d16db-0:1:163422) at o.handleOpenQueries (http://nc/dist/files-main.js?v=106d16db-0:1:163167) at o.openDetails (http://nc/dist/files-main.js?v=106d16db-0:1:162349) at fn (http://nc/dist/core-common.js?v=106d16db-0:1:3942538) at e.run (http://nc/dist/core-common.js?v=106d16db-0:1:3946900) at sa (http://nc/dist/core-common.js?v=106d16db-0:1:3948728) at Array.<anonymous> (http://nc/dist/core-common.js?v=106d16db-0:1:3943585) at bn (http://nc/dist/core-common.js?v=106d16db-0:1:3942986)level: 2uid: "admin" [[Prototype]]: Object log @ index.mjs:54 Possibly regression from e700102 Fixes nextcloud/richdocuments#3815 Signed-off-by: Szymon Kłos <[email protected]>
1 parent 815338c commit 058dd55

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/files/src/actions/sidebarAction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ export const action = new FileAction({
4343
async exec(node: Node, view: View, dir: string) {
4444
try {
4545
// If the sidebar is already open for the current file, do nothing
46-
if (window.OCA.Files.Sidebar.file === node.path) {
46+
if (window.OCA.Files?.Sidebar?.file === node.path) {
4747
logger.debug('Sidebar already open for this file', { node })
4848
return null
4949
}
5050
// Open sidebar and set active tab to sharing by default
51-
window.OCA.Files.Sidebar.setActiveTab('sharing')
51+
window.OCA.Files?.Sidebar?.setActiveTab('sharing')
5252

5353
// TODO: migrate Sidebar to use a Node instead
54-
await window.OCA.Files.Sidebar.open(node.path)
54+
await window.OCA.Files?.Sidebar?.open(node.path)
5555

5656
// Silently update current fileid
5757
window.OCP?.Files?.Router?.goToRoute(

0 commit comments

Comments
 (0)