From 016be73c6c7e0e005a04fd8a3e35a48193d14f13 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Tue, 3 Feb 2026 16:25:31 +0100 Subject: [PATCH] improve page-create --- docs/MONETIZATION.md | 2 +- js/components/pages/page-create.js | 71 ++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/docs/MONETIZATION.md b/docs/MONETIZATION.md index 5e32a3b..7408e2d 100644 --- a/docs/MONETIZATION.md +++ b/docs/MONETIZATION.md @@ -42,7 +42,7 @@ - Keine externe Abhängigkeit, keine Lizenzkosten - Client löst SHA256-Challenge (Difficulty 4, ~1-3 Sek) - Bei Account-Erstellung (immer) -- Bei Anzeigen-Erstellung (immer) +- Bei Anzeigen-Erstellung (nur neue Accounts ohne bisherige Listings) - Bei Login (nur nach 3+ Fehlversuchen) - Implementierung: `js/services/pow-captcha.js`, `js/components/pow-captcha.js` diff --git a/js/components/pages/page-create.js b/js/components/pages/page-create.js index dc4fd40..57c7d51 100644 --- a/js/components/pages/page-create.js +++ b/js/components/pages/page-create.js @@ -28,6 +28,7 @@ class PageCreate extends HTMLElement { this.imagePreviews = [] this.categories = [] this.submitting = false + this.isNewAccount = true } loadDraft() { @@ -60,28 +61,56 @@ class PageCreate extends HTMLElement { this.hasDraft = !!localStorage.getItem(STORAGE_KEY) await this.loadCategories() + await this.checkAccountStatus() this.render() this.unsubscribe = i18n.subscribe(() => this.render()) } + async checkAccountStatus() { + try { + // Check if user has any published listings + const user = await auth.getUser() + if (user?.id) { + const listings = await directus.get('/items/listings', { + filter: { user_created: { _eq: user.id } }, + limit: 1 + }) + this.isNewAccount = !listings.data || listings.data.length === 0 + } + } catch (e) { + // Default to new account (show captcha) + this.isNewAccount = true + } + } + showLoginRequired() { + // Show login modal directly + const authModal = document.querySelector('auth-modal') + if (authModal) { + authModal.show('login') + authModal.addEventListener('login', async () => { + // After login, load the create page + this.hasDraft = !!localStorage.getItem(STORAGE_KEY) + await this.loadCategories() + this.render() + this.unsubscribe = i18n.subscribe(() => this.render()) + }, { once: true }) + authModal.addEventListener('close', () => { + // If closed without login, go back + if (!auth.isLoggedIn()) { + router.back() + } + }, { once: true }) + } + + // Show minimal loading state while modal is open this.innerHTML = /* html */`
` - this.querySelector('#login-btn')?.addEventListener('click', () => { - const authModal = document.querySelector('auth-modal') - if (authModal) { - authModal.show('login') - authModal.addEventListener('login', () => { - this.connectedCallback() - }, { once: true }) - } - }) } async loadCategories() { @@ -249,9 +278,11 @@ class PageCreate extends HTMLElement {

${t('create.moneroHint')}

-
- -
+ ${this.isNewAccount ? ` +
+ +
+ ` : ''}