Skip to content

Commit

Permalink
refactoring to remove "timed-call" dependency from viewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
bago committed Nov 4, 2022
1 parent d7aeec5 commit 2630190
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/js/template-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ var templateCompiler = function(performanceAwareCaller, templateUrlConverter, te
plugins.push(templatesPlugin);

// initialize the viewModel object based on the content model.
var viewModel = performanceAwareCaller('initializeViewmodel', initializeViewmodel.bind(this, content, blockModels.blockList, templateUrlConverter, galleryUrl, modelImporter, exportCleanedHTML));
var viewModel = performanceAwareCaller('initializeViewmodel', initializeViewmodel.bind(this, content, blockModels.blockList, templateUrlConverter, galleryUrl, modelImporter, timedExportCleanedHTML.bind(undefined, performanceAwareCaller)));

viewModel.metadata = metadata;
// let's run some version check on template and editor used to build the model being loaded.
Expand Down Expand Up @@ -433,6 +433,10 @@ function conditional_restore(html) {
});
}

function timedExportCleanedHTML(performanceAwareCaller, viewModel) {
return performanceAwareCaller("exportCleanedHTML", viewModel);
}

function exportCleanedHTML(viewModel) {
var id = 'exportframe';
$('body').append('<iframe id="' + id + '" data-bind="bindIframe: $data"></iframe>');
Expand Down
9 changes: 2 additions & 7 deletions src/js/viewmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var $ = require("jquery");
var ko = require("knockout");
var console = require("console");
var performanceAwareCaller = require("./timed-call.js").timedCall;

var toastr = require("toastr");
toastr.options = {
Expand Down Expand Up @@ -347,12 +346,8 @@ function initializeEditor(content, blocks, thumbPathConverter, galleryUrl, conte
global.setTimeout(viewModel.loopSubscriptionsCount, 1000);
};

viewModel.export = function() {
var content = performanceAwareCaller("exportHTML", viewModel.exportHTML);
return content;
};

viewModel.exportHTML = function() {
// before 0.18.8 "export" used to log exportHTML timing, but we moved that in the internal exporter function.
viewModel.export = viewModel.exportHTML = function() {
content = exportCleanedHTML(viewModel);

// Remove trash leftover by TinyMCE
Expand Down

0 comments on commit 2630190

Please sign in to comment.