Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit da9a2e1

Browse files
committed
added a force reload command for live preview
1 parent b638f13 commit da9a2e1

6 files changed

Lines changed: 30 additions & 13 deletions

File tree

src/LiveDevelopment/LiveDevelopment.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,19 @@ define(function LiveDevelopment(require, exports, module) {
921921
return loadAgents();
922922
}
923923

924+
/** reload the live preview */
925+
function reload() {
926+
// Unload and reload agents before reloading the page
927+
// Some agents (e.g. DOMAgent and RemoteAgent) require us to
928+
// navigate to the page first before loading can complete.
929+
// To accomodate this, we load all agents (in reconnect())
930+
// and navigate in parallel.
931+
reconnect();
932+
933+
// Reload HTML page
934+
Inspector.Page.reload();
935+
}
936+
924937
/**
925938
* Close the connection and the associated window asynchronously
926939
* @return {jQuery.Promise} Resolves once the connection is closed
@@ -1368,15 +1381,7 @@ define(function LiveDevelopment(require, exports, module) {
13681381
wasRequested = agents.network && agents.network.wasURLRequested(documentUrl);
13691382

13701383
if (wasRequested) {
1371-
// Unload and reload agents before reloading the page
1372-
// Some agents (e.g. DOMAgent and RemoteAgent) require us to
1373-
// navigate to the page first before loading can complete.
1374-
// To accomodate this, we load all agents (in reconnect())
1375-
// and navigate in parallel.
1376-
reconnect();
1377-
1378-
// Reload HTML page
1379-
Inspector.Page.reload();
1384+
reload();
13801385
}
13811386
}
13821387

@@ -1447,6 +1452,7 @@ define(function LiveDevelopment(require, exports, module) {
14471452
exports.open = open;
14481453
exports.close = close;
14491454
exports.reconnect = reconnect;
1455+
exports.reload = reload;
14501456
exports.enableAgent = enableAgent;
14511457
exports.disableAgent = disableAgent;
14521458
exports.getLiveDocForPath = getLiveDocForPath;

src/LiveDevelopment/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ define(function main(require, exports, module) {
226226
window.report = function report(params) { window.params = params; console.info(params); };
227227
}
228228

229+
/** force reload the live preview */
230+
function _handleReloadLivePreviewCommand() {
231+
if (LiveDevelopment.status >= LiveDevelopment.STATUS_ACTIVE) {
232+
LiveDevelopment.reload();
233+
}
234+
}
235+
229236
/** Initialize LiveDevelopment */
230237
AppInit.appReady(function () {
231238
params.parse();
@@ -275,6 +282,7 @@ define(function main(require, exports, module) {
275282
// init commands
276283
CommandManager.register(Strings.CMD_LIVE_FILE_PREVIEW, Commands.FILE_LIVE_FILE_PREVIEW, _handleGoLiveCommand);
277284
CommandManager.register(Strings.CMD_LIVE_HIGHLIGHT, Commands.FILE_LIVE_HIGHLIGHT, _handlePreviewHighlightCommand);
285+
CommandManager.register(Strings.CMD_RELOAD_LIVE_PREVIEW, Commands.FILE_RELOAD_LIVE_PREVIEW, _handleReloadLivePreviewCommand);
278286
CommandManager.get(Commands.FILE_LIVE_HIGHLIGHT).setEnabled(false);
279287

280288
// Export public functions

src/base-config/keyboard.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
"file.liveFilePreview": [
2727
"Ctrl-Alt-P"
2828
],
29+
"file.reloadLivePreview": [
30+
{
31+
"key": "Ctrl-Shift-R"
32+
}
33+
],
2934
"file.previewHighlight": [
3035
"Ctrl-Shift-C"
3136
],

src/command/Commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ define(function (require, exports, module) {
6767
exports.FILE_ADD_TO_WORKING_SET = "file.addToWorkingSet"; // DocumentCommandHandlers.js handleFileAddToWorkingSet()
6868
exports.FILE_OPEN_DROPPED_FILES = "file.openDroppedFiles"; // DragAndDrop.js openDroppedFiles()
6969
exports.FILE_LIVE_FILE_PREVIEW = "file.liveFilePreview"; // LiveDevelopment/main.js _handleGoLiveCommand()
70+
exports.FILE_RELOAD_LIVE_PREVIEW = "file.reloadLivePreview"; // LiveDevelopment/main.js _handleGoLiveCommand()
7071
exports.FILE_LIVE_HIGHLIGHT = "file.previewHighlight"; // LiveDevelopment/main.js _handlePreviewHighlightCommand()
7172
exports.FILE_PROJECT_SETTINGS = "file.projectSettings"; // ProjectManager.js _projectSettings()
7273
exports.FILE_RENAME = "file.rename"; // DocumentCommandHandlers.js handleFileRename()

src/extensions/default/DebugCommands/keyboard.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
"reloadWithoutUserExts": [
2121
{
2222
"key": "Shift-F5"
23-
},
24-
{
25-
"key": "Cmd-Shift-R",
26-
"platform": "mac"
2723
}
2824
]
2925
}

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ define({
276276
"CMD_FILE_SAVE_ALL" : "Save All",
277277
"CMD_FILE_SAVE_AS" : "Save As\u2026",
278278
"CMD_LIVE_FILE_PREVIEW" : "Live Preview",
279+
"CMD_RELOAD_LIVE_PREVIEW" : "Force Reload Live Preview",
279280
"CMD_PROJECT_SETTINGS" : "Project Settings\u2026",
280281
"CMD_FILE_RENAME" : "Rename",
281282
"CMD_FILE_DELETE" : "Delete",

0 commit comments

Comments
 (0)