Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Add promptbox for first time external site visit #2411

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions javascript/photopea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down