Skip to content

Commit 7e8f524

Browse files
committed
chore: reload live preview working and reload liev perview menu item in file menu
1 parent 2ed123d commit 7e8f524

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ define(function (require, exports, module) {
233233
processedMessageIDs.set(messageID, true);
234234
}
235235
if(_livePreviewMessageHandler) {
236-
_livePreviewMessageHandler(msg);
236+
let preventDefault = _livePreviewMessageHandler(msg);
237+
if(preventDefault){
238+
return;
239+
}
237240
}
238241

239242
if (msg.id) {

src/LiveDevelopment/main.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ define(function main(require, exports, module) {
8686

8787
// update the config with the new state
8888
config.imageGalleryState = state;
89-
if (MultiBrowserLiveDev && MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {
90-
MultiBrowserLiveDev.updateConfig(JSON.stringify(config));
91-
}
89+
refreshConfigInLivePreview();
9290
}
9391

9492
let params = new UrlParams();
@@ -222,13 +220,6 @@ define(function main(require, exports, module) {
222220
});
223221
}
224222

225-
/** force reload the live preview currently only with shortcut ctrl-shift-R */
226-
function _handleReloadLivePreviewCommand() {
227-
if (MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {
228-
MultiBrowserLiveDev.reload();
229-
}
230-
}
231-
232223
/**
233224
* Internal api used to update live edit capability status as entitlements changes. calling this will update the UI
234225
* but will not functionally enable live editing capabilities as that are dependent on entitlements framework.
@@ -315,7 +306,10 @@ define(function main(require, exports, module) {
315306
return;
316307
}
317308
config.mode = currentMode;
309+
refreshConfigInLivePreview();
310+
}
318311

312+
function refreshConfigInLivePreview() {
319313
if (MultiBrowserLiveDev && MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {
320314
MultiBrowserLiveDev.updateConfig(JSON.stringify(config));
321315
}
@@ -326,22 +320,15 @@ define(function main(require, exports, module) {
326320
function updateElementHighlightConfig() {
327321
const prefValue = PreferencesManager.get("livePreviewElementHighlights");
328322
config.elemHighlights = prefValue || "hover";
329-
if (MultiBrowserLiveDev && MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {
330-
MultiBrowserLiveDev.updateConfig(JSON.stringify(config));
331-
}
323+
refreshConfigInLivePreview();
332324
}
333325

334326
function updateRulerLinesConfig() {
335327
const prefValue = PreferencesManager.get("livePreviewShowRulerLines");
336328
config.showRulerLines = prefValue || false;
337-
if (MultiBrowserLiveDev && MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {
338-
MultiBrowserLiveDev.updateConfig(JSON.stringify(config));
339-
}
329+
refreshConfigInLivePreview();
340330
}
341331

342-
// init commands
343-
CommandManager.register(Strings.CMD_RELOAD_LIVE_PREVIEW, Commands.CMD_RELOAD_LIVE_PREVIEW, _handleReloadLivePreviewCommand);
344-
345332
EventDispatcher.makeEventDispatcher(exports);
346333

347334
// private api

src/extensionsIntegrated/Phoenix-live-preview/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,10 +1199,15 @@ define(function (require, exports, module) {
11991199
});
12001200
CommandManager.register(Strings.CMD_LIVE_FILE_PREVIEW_SETTINGS,
12011201
Commands.FILE_LIVE_FILE_PREVIEW_SETTINGS, _showSettingsDialog);
1202+
CommandManager.register(Strings.CMD_RELOAD_LIVE_PREVIEW, Commands.CMD_RELOAD_LIVE_PREVIEW, function () {
1203+
_loadPreview(true, true);
1204+
});
12021205
let fileMenu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU);
12031206
fileMenu.addMenuItem(Commands.FILE_LIVE_FILE_PREVIEW, "", Menus.AFTER, Commands.FILE_EXTENSION_MANAGER);
1204-
fileMenu.addMenuItem(Commands.FILE_LIVE_FILE_PREVIEW_SETTINGS, "",
1207+
fileMenu.addMenuItem(Commands.CMD_RELOAD_LIVE_PREVIEW, "",
12051208
Menus.AFTER, Commands.FILE_LIVE_FILE_PREVIEW);
1209+
fileMenu.addMenuItem(Commands.FILE_LIVE_FILE_PREVIEW_SETTINGS, "",
1210+
Menus.AFTER, Commands.CMD_RELOAD_LIVE_PREVIEW);
12061211
fileMenu.addMenuDivider(Menus.BEFORE, Commands.FILE_LIVE_FILE_PREVIEW);
12071212

12081213
_registerHandlers();

src/nls/root/strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ define({
543543
"CMD_LIVE_FILE_PREVIEW": "Live Preview",
544544
"CMD_LIVE_FILE_PREVIEW_SETTINGS": "Live Preview Settings",
545545
"CMD_TOGGLE_LIVE_PREVIEW_MB_MODE": "Enable Experimental Live Preview",
546-
"CMD_RELOAD_LIVE_PREVIEW": "Force Reload Live Preview",
546+
"CMD_RELOAD_LIVE_PREVIEW": "Reload Live Preview",
547547
"CMD_PROJECT_SETTINGS": "Project Settings\u2026",
548548
"CMD_FILE_RENAME": "Rename",
549549
"CMD_FILE_DELETE": "Delete",

0 commit comments

Comments
 (0)