U4-10504 Previewing content results in the same PrepareDocument (expensive) procedure to be executed 3 times
This commit is contained in:
@@ -7,12 +7,22 @@ var app = angular.module("Umbraco.canvasdesigner", ['colorpicker', 'ui.slider',
|
||||
|
||||
.controller("Umbraco.canvasdesignerController", function ($scope, $http, $window, $timeout, $location, dialogService) {
|
||||
|
||||
var isInit = $location.search().init;
|
||||
if (isInit === "true") {
|
||||
//do not continue, this is the first load of this new window, if this is passed in it means it's been
|
||||
//initialized by the content editor and then the content editor will actually re-load this window without
|
||||
//this flag. This is a required trick to get around chrome popup mgr. We don't want to double load preview.aspx
|
||||
//since that will double prepare the preview documents
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.isOpen = false;
|
||||
$scope.frameLoaded = false;
|
||||
$scope.enableCanvasdesigner = 0;
|
||||
$scope.googleFontFamilies = {};
|
||||
$scope.pageId = $location.search().id;
|
||||
$scope.pageUrl = "../dialogs/Preview.aspx?id=" + $location.search().id;
|
||||
var pageId = $location.search().id;
|
||||
$scope.pageId = pageId;
|
||||
$scope.pageUrl = "../dialogs/Preview.aspx?id=" + pageId;
|
||||
$scope.valueAreLoaded = false;
|
||||
$scope.devices = [
|
||||
{ name: "desktop", css: "desktop", icon: "icon-display", title: "Desktop" },
|
||||
|
||||
@@ -208,9 +208,9 @@
|
||||
if (!$scope.busy) {
|
||||
|
||||
// Chromes popup blocker will kick in if a window is opened
|
||||
// outwith the initial scoped request. This trick will fix that.
|
||||
// without the initial scoped request. This trick will fix that.
|
||||
//
|
||||
var previewWindow = $window.open('preview/?id=' + content.id, 'umbpreview');
|
||||
var previewWindow = $window.open('preview/?init=true&id=' + content.id, 'umbpreview');
|
||||
|
||||
// Build the correct path so both /#/ and #/ work.
|
||||
var redirect = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/preview/?id=' + content.id;
|
||||
|
||||
@@ -643,9 +643,7 @@ namespace Umbraco.Web.Editors
|
||||
ShowMessageForPublishStatus(publishStatus.Result, display);
|
||||
break;
|
||||
}
|
||||
|
||||
UpdatePreviewContext(contentItem.PersistedContent.Id);
|
||||
|
||||
|
||||
//If the item is new and the operation was cancelled, we need to return a different
|
||||
// status code so the UI can handle it since it won't be able to redirect since there
|
||||
// is no Id to redirect to!
|
||||
@@ -875,24 +873,6 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the user is currently in preview mode and if so will update the preview content for this item
|
||||
/// </summary>
|
||||
/// <param name="contentId"></param>
|
||||
private void UpdatePreviewContext(int contentId)
|
||||
{
|
||||
var previewId = Request.GetPreviewCookieValue();
|
||||
if (previewId.IsNullOrWhiteSpace()) return;
|
||||
Guid id;
|
||||
if (Guid.TryParse(previewId, out id))
|
||||
{
|
||||
var d = new Document(contentId);
|
||||
var pc = new PreviewContent(UmbracoUser, id, false);
|
||||
pc.PrepareDocument(UmbracoUser, d, true);
|
||||
pc.SavePreviewSet();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps the dto property values to the persisted model
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user