Skip to content

Commit

Permalink
fix: open publish url was not working in tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Oct 18, 2023
1 parent 308a07c commit a7b4b8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/extensions/default/Phoenix/guided-tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ define(function (require, exports, module) {
Metrics.countEvent(Metrics.EVENT_TYPE.USER, "notify", "twit.click", 1);
if(Phoenix.browser.isTauri) {
// hyperlinks wont work in tauri, so we have to use tauri apis
window.top.Phoenix.app.openURLInDefaultBrowser(
Phoenix.app.openURLInDefaultBrowser(
'https://twitter.com/intent/tweet?screen_name=phcodedev&ref_src=twsrc%5Etfw');
}
});
Expand Down Expand Up @@ -243,7 +243,7 @@ define(function (require, exports, module) {
Metrics.countEvent(Metrics.EVENT_TYPE.USER, "notify", "star.click", 1);
if(Phoenix.browser.isTauri) {
// hyperlinks wont work in tauri, so we have to use tauri apis
window.top.Phoenix.app.openURLInDefaultBrowser(
Phoenix.app.openURLInDefaultBrowser(
'https://github.com/phcode-dev/phoenix');
}
});
Expand Down
26 changes: 2 additions & 24 deletions src/extensions/default/Phoenix/serverSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ define(function (require, exports, module) {

const ProjectManager = brackets.getModule("project/ProjectManager"),
DocumentManager = brackets.getModule("document/DocumentManager"),
EditorManager = brackets.getModule("editor/EditorManager"),
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
Dialogs = brackets.getModule("widgets/Dialogs"),
Strings = brackets.getModule("strings"),
Expand All @@ -44,9 +43,7 @@ define(function (require, exports, module) {
let syncEnabled = false;
let projectSyncStarted = false;
let projectSyncCompleted = false;
let tab = null;
let previewURL;
let previewInProgress = false;

function _setupUserContext() {
userContext = localStorage.getItem(USER_CONTEXT);
Expand Down Expand Up @@ -233,7 +230,6 @@ define(function (require, exports, module) {
if (id === Dialogs.DIALOG_BTN_OK) {
syncEnabled = true;
_startSync(()=>{
previewInProgress = true;
_loadPreview();
});
}
Expand All @@ -249,10 +245,7 @@ define(function (require, exports, module) {
return false;
}

function _loadPreview() {
if(!previewInProgress){
return;
}
async function _loadPreview() {
let projectRootUrl = _getProjectPreviewURL();
let currentDocument = DocumentManager.getCurrentDocument();
let currentFile = currentDocument? currentDocument.file : ProjectManager.getSelectedItem();
Expand All @@ -268,12 +261,7 @@ define(function (require, exports, module) {
if(!previewURL){
previewURL = projectRootUrl;
}
if(!tab || tab.closed){
tab = open(previewURL);
}
else {
tab.location = previewURL;
}
Phoenix.app.openURLInDefaultBrowser(previewURL);
}

function _addToolbarIcon() {
Expand All @@ -289,7 +277,6 @@ define(function (require, exports, module) {
$icon.on('click', ()=>{
Metrics.countEvent(Metrics.EVENT_TYPE.SHARING, "shareIcon", "clicked");
if(projectSyncCompleted){
previewInProgress = true;
_setSyncInProgress();
let uniqueFilesToUpload = [...new Set(allChangedFiles)];
allChangedFiles = [];
Expand All @@ -302,20 +289,11 @@ define(function (require, exports, module) {
});
}

setInterval(()=>{
// periodically check if the preview tab is manually closed by user. We do this by light polling as
// we cannot attach an onTabClosed event to the tab.
if(previewInProgress && (!tab || tab.closed)){
previewInProgress = false;
}
}, 500);

exports.init = function () {
_addToolbarIcon();
_setupUserContext();
ProjectManager.on(ProjectManager.EVENT_PROJECT_OPEN, _projectOpened);
ProjectManager.on(ProjectManager.EVENT_PROJECT_FILE_CHANGED, _projectFileChanged);
EditorManager.on("activeEditorChange", _loadPreview);
};

ExtensionUtils.loadStyleSheet(module, "styles.css");
Expand Down

0 comments on commit a7b4b8b

Please sign in to comment.