Skip to content

Commit 5d6eb0f

Browse files
committed
refactor: 1sec delay in mac to open live preview panel at start
1 parent 6ead779 commit 5d6eb0f

File tree

4 files changed

+6
-39
lines changed

4 files changed

+6
-39
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -789,20 +789,14 @@ define(function (require, exports, module) {
789789
let fileChangeListenerStartDelay = 0;
790790
if(Phoenix.isNativeApp && Phoenix.platform === "mac") {
791791
// in mac, if we do the `open with Phoenix Code` from finder, then, the open with events come as events
792-
// after app start. This causes a problem where if we opens a txt file with open with, and and html file was
792+
// after app start. This causes a problem where if we open a txt file with open with, and an html file was
793793
// open previously, then currentFileChange listener will see the html file at first and open the live
794794
// preview panel, and immediately, the txt file event will be sent by os resulting in a no preview page.
795795
// we should not show a no preview page for opening txt / non-previewable files. So, we dont attach the
796-
// change listener in macos for a few seconds, and attach the listener if the user explicitly clicks on a
797-
// file.
798-
fileChangeListenerStartDelay = 500;
799-
ProjectManager.on(ProjectManager.EVENT_FILE_CLICKED_SIDEBAR, ()=>{
800-
MainViewManager.off("currentFileChange", _currentFileChanged);
801-
MainViewManager.on("currentFileChange", _currentFileChanged);
802-
});
796+
// change listener in macos for a second to give some time for the os event to reach.
797+
fileChangeListenerStartDelay = 600;
803798
}
804799
setTimeout(()=>{
805-
MainViewManager.off("currentFileChange", _currentFileChanged);
806800
MainViewManager.on("currentFileChange", _currentFileChanged);
807801
if(Phoenix.isNativeApp && Phoenix.platform === "mac" && MainViewManager.getCurrentlyViewedFile()) {
808802
_currentFileChanged(null, MainViewManager.getCurrentlyViewedFile());

src/project/FileTreeView.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ define(function (require, exports, module) {
3737
LanguageManager = require("language/LanguageManager"),
3838
FileTreeViewModel = require("project/FileTreeViewModel"),
3939
ViewUtils = require("utils/ViewUtils"),
40-
KeyEvent = require("utils/KeyEvent"),
41-
EventDispatcher = require("utils/EventDispatcher");
42-
43-
EventDispatcher.makeEventDispatcher(exports);
44-
45-
const EVENT_FILE_NODE_CLICKED_IN_TREE = "fileNodeClickedInTree";
40+
KeyEvent = require("utils/KeyEvent");
4641

4742
var DOM = Preact.DOM;
4843

@@ -588,7 +583,6 @@ define(function (require, exports, module) {
588583
}
589584
this.props.actions.setSelected(this.myPath(), doNotOpen);
590585
this.render();
591-
exports.trigger(EVENT_FILE_NODE_CLICKED_IN_TREE);
592586
},
593587

594588
/**
@@ -1337,6 +1331,4 @@ define(function (require, exports, module) {
13371331
exports.addClassesProvider = addClassesProvider;
13381332
exports.render = render;
13391333

1340-
// private events
1341-
exports._EVENT_FILE_NODE_CLICKED_IN_TREE = EVENT_FILE_NODE_CLICKED_IN_TREE;
13421334
});

src/project/ProjectManager.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ define(function (require, exports, module) {
9393
EVENT_PROJECT_REFRESH = "projectRefresh",
9494
EVENT_CONTENT_CHANGED = "contentChanged",
9595
EVENT_PROJECT_FILE_CHANGED = "projectFileChanged",
96-
EVENT_PROJECT_FILE_RENAMED = "projectFileRenamed",
97-
EVENT_FILE_CLICKED_SIDEBAR = "fileClickedSidebar";
96+
EVENT_PROJECT_FILE_RENAMED = "projectFileRenamed";
9897

9998
EventDispatcher.setLeakThresholdForEvent(EVENT_PROJECT_OPEN, 25);
10099

@@ -2216,14 +2215,6 @@ define(function (require, exports, module) {
22162215
_renderTree(true);
22172216
}
22182217

2219-
FileTreeView.on(FileTreeView._EVENT_FILE_NODE_CLICKED_IN_TREE, ()=>{
2220-
exports.trigger(EVENT_FILE_CLICKED_SIDEBAR);
2221-
});
2222-
2223-
WorkingSetView.on(WorkingSetView._EVENT_FILE_NODE_CLICKED_WORKING_SET, ()=>{
2224-
exports.trigger(EVENT_FILE_CLICKED_SIDEBAR);
2225-
});
2226-
22272218

22282219
// Private API helpful in testing
22292220
exports._actionCreator = actionCreator;
@@ -2281,5 +2272,4 @@ define(function (require, exports, module) {
22812272
exports.EVENT_PROJECT_FILE_CHANGED = EVENT_PROJECT_FILE_CHANGED;
22822273
exports.EVENT_PROJECT_FILE_RENAMED = EVENT_PROJECT_FILE_RENAMED;
22832274
exports.EVENT_PROJECT_OPEN_FAILED = EVENT_PROJECT_OPEN_FAILED;
2284-
exports.EVENT_FILE_CLICKED_SIDEBAR = EVENT_FILE_CLICKED_SIDEBAR;
22852275
});

src/project/WorkingSetView.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ define(function (require, exports, module) {
4343
paneListTemplate = require("text!htmlContent/working-set.html"),
4444
Strings = require("strings"),
4545
_ = require("thirdparty/lodash"),
46-
Mustache = require("thirdparty/mustache/mustache"),
47-
EventDispatcher = require("utils/EventDispatcher");
48-
49-
EventDispatcher.makeEventDispatcher(exports);
50-
51-
const EVENT_FILE_NODE_CLICKED_WORKING_SET = "fileNodeClickedWorkingSet";
46+
Mustache = require("thirdparty/mustache/mustache");
5247

5348
/**
5449
* Open view dictionary
@@ -281,7 +276,6 @@ define(function (require, exports, module) {
281276

282277
// The mouse down handler pretty much handles everything
283278
$el.mousedown(function (e) {
284-
exports.trigger(EVENT_FILE_NODE_CLICKED_WORKING_SET);
285279
var scrollDir = 0,
286280
dragged = false,
287281
startPageY = e.pageY,
@@ -1587,7 +1581,4 @@ define(function (require, exports, module) {
15871581
// API to be used only by default extensions
15881582
exports.useIconProviders = useIconProviders;
15891583
exports.useClassProviders = useClassProviders;
1590-
1591-
// private events
1592-
exports._EVENT_FILE_NODE_CLICKED_WORKING_SET = EVENT_FILE_NODE_CLICKED_WORKING_SET;
15931584
});

0 commit comments

Comments
 (0)