diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index 9c6ee001c0..67ea131c92 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -60,7 +60,7 @@ define([ 'btn-save': 'save', 'btn-save-coauth': 'coauth', 'btn-synch': 'synch' }; - let recents; + let recents = []; var nativevars, helpUrl; @@ -163,7 +163,7 @@ define([ window.onupdaterecents = function (params) { recents = _parseRecents(params); - Common.NotificationCenter.trigger('update:recents'); + Common.NotificationCenter.trigger('update:recents', recents); } // hide mask for modal window @@ -593,8 +593,8 @@ define([ name: Common.Utils.String.htmlDecode(model.get('title')), path: Common.Utils.String.htmlDecode(model.get('url')), }; - if ( model.get('fileid') ) { - params.id = model.fileid; + if ( model.get('fileid') != undefined && model.get('fileid') != null ) { + params.id = model.get('fileid'); params.type = model.type; } else { params.id = -1; diff --git a/apps/common/main/lib/view/RecentFiles.js b/apps/common/main/lib/view/RecentFiles.js index 83729ce42d..8d1e7a9487 100644 --- a/apps/common/main/lib/view/RecentFiles.js +++ b/apps/common/main/lib/view/RecentFiles.js @@ -61,6 +61,15 @@ define([ this.menu = options.menu; this.recent = options.recent; this.el = options.el; + + Common.NotificationCenter.on('update:recents', function (arr) { + if ( this.viewRecentPicker ) { + const store = this.viewRecentPicker.store; + if ( store ) { + store.reset(this.recent.concat(arr)) + } + } + }.bind(this)); }, render: function() { @@ -102,7 +111,8 @@ define([ onRecentFileClick: function(view, itemview, record){ if ( this.menu ) { - !Common.Controllers.Desktop.openRecent(record) && this.menu.fireEvent('recent:open', [this.menu, record.get('url')]); + !Common.Controllers.Desktop.openRecent(record) && + this.menu.fireEvent('recent:open', [this.menu, record.get('url')]); } }, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 5b7cc557e0..9ed96540b1 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -421,10 +421,8 @@ define([ this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id); this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop' || Common.Controllers.Desktop.isActive(); - if(this.appOptions.isDesktopApp){ - var desktopRecent = Common.Controllers.Desktop.recentFiles(); - if (desktopRecent && desktopRecent.length > 0) - this.editorConfig.recent = !this.editorConfig.recent ? desktopRecent : this.editorConfig.recent = this.editorConfig.recent.concat(desktopRecent); + if( Common.Controllers.Desktop.isActive() ){ + !this.editorConfig.recent && (this.editorConfig.recent = []); } this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl) || this.editorConfig.templates && this.editorConfig.templates.length; diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index 8af99c9d3e..86e3b4927a 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -334,8 +334,13 @@ define([ me.scroller.update(); }); } + this.applyMode(); + if ( Common.Controllers.Desktop.isActive() ) { + Common.NotificationCenter.trigger('update:recents', Common.Controllers.Desktop.recentFiles()); + } + if ( !!this.api ) { this.panels['info'].setApi(this.api); if (this.panels['opts']) this.panels['opts'].setApi(this.api);