Skip to content

Commit 3314f2f

Browse files
committed
chore: redictable switch between preview and edit mode with play button
1 parent 080a53a commit 3314f2f

1 file changed

Lines changed: 6 additions & 21 deletions

File tree

  • src/extensionsIntegrated/Phoenix-live-preview

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

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ define(function (require, exports, module) {
150150

151151
let customLivePreviewBannerShown = false;
152152

153-
// so this variable stores the mode that was previously selected
154-
// this is needed when the preview mode (play button icon) is clicked, we store the current mode
155-
// so that when user unclicks the button we can revert back to the mode that was originally selected
156-
let modeThatWasSelected = null;
157-
158153
// live Preview overlay variables (overlays are shown when live preview is connecting or there's a syntax error)
159154
let $statusOverlay = null; // reference to the static overlay element
160155
let $statusOverlayMessage = null; // reference to the message span
@@ -667,28 +662,18 @@ define(function (require, exports, module) {
667662
}
668663

669664
/**
670-
* This function is called when user clicks the preview mode button (play button icon)
671-
* when this button is clicked we switch the mode button dropdown to preview mode
665+
* Handle preview button click - toggles between preview mode and the user's default mode.
666+
* PRO users toggle between preview and edit mode.
667+
* community users toggle between preview and highlight mode.
672668
*/
673669
function _handlePreviewBtnClick() {
674670
if($previewBtn.hasClass('selected')) {
675671
$previewBtn.removeClass('selected');
676-
const isEditFeaturesActive = isProEditUser;
677-
if(modeThatWasSelected) {
678-
// If the last selected mode was preview itself, default to the best mode for user's entitlement
679-
if(modeThatWasSelected === 'preview') {
680-
const defaultMode = isEditFeaturesActive ? 'edit' : 'highlight';
681-
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, defaultMode);
682-
} else if(modeThatWasSelected === 'edit' && !isEditFeaturesActive) {
683-
// Non-pro users can't be in edit mode - switch to highlight
684-
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "highlight");
685-
} else {
686-
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, modeThatWasSelected);
687-
}
688-
}
672+
const defaultMode = isProEditUser ? 'edit' : 'highlight';
673+
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, defaultMode);
689674
} else {
675+
// Currently NOT in preview mode - switch to preview
690676
$previewBtn.addClass('selected');
691-
modeThatWasSelected = PreferencesManager.get(PREFERENCE_LIVE_PREVIEW_MODE);
692677
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "preview");
693678
}
694679
}

0 commit comments

Comments
 (0)