From a4efa16920e55b77f93336e13afe2e94d77a9640 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Fri, 5 Jan 2024 11:21:04 -0500 Subject: [PATCH 1/2] :wrench: Add promptbox for first time external site visit --- javascript/photopea.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/javascript/photopea.js b/javascript/photopea.js index 58a5663b8..7265bd930 100644 --- a/javascript/photopea.js +++ b/javascript/photopea.js @@ -375,6 +375,18 @@ } } + function firstTimeUserPrompt() { + if (localStorage.getItem("ControlNetPhotopeaEditPrompted")) { + return true; + } else { + localStorage.setItem("ControlNetPhotopeaEditPrompted", "true"); + } + const promptMsg = "This is the first time you use photopea edit feature. The preprocess results are " + "going to be send to https://photopea.com for edit. You can disable photopea edit in Settings > ControlNet" + " > Disable photopea edit."; + return confirm(promptMsg); + } + const cnetRegisteredAccordions = new Set(); function loadPhotopea() { function registerCallbacks(accordion) { @@ -393,6 +405,8 @@ tabs.forEach(tab => { const photopeaChildTrigger = tab.querySelector('.cnet-photopea-child-trigger'); photopeaChildTrigger.addEventListener('click', async () => { + if (!firstTimeUserPrompt()) return; + photopeaMainTrigger.click(); if (await photopeaContext.invoke(hasActiveDocument) === "false") { await photopeaContext.fetchFromControlNet(tabs); From dae3e94b7a34d21d53bae0fe1b5c3a5182c47bbe Mon Sep 17 00:00:00 2001 From: huchenlei Date: Fri, 5 Jan 2024 11:24:01 -0500 Subject: [PATCH 2/2] nits --- javascript/photopea.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javascript/photopea.js b/javascript/photopea.js index 7265bd930..070412e18 100644 --- a/javascript/photopea.js +++ b/javascript/photopea.js @@ -381,8 +381,8 @@ } else { localStorage.setItem("ControlNetPhotopeaEditPrompted", "true"); } - const promptMsg = "This is the first time you use photopea edit feature. The preprocess results are " - "going to be send to https://photopea.com for edit. You can disable photopea edit in Settings > ControlNet" + const promptMsg = "This is the first time you use photopea edit feature. The preprocess results are " + + "going to be send to https://photopea.com for edit. You can disable photopea edit in Settings > ControlNet" + " > Disable photopea edit."; return confirm(promptMsg); }