From aa21dc3ad64a33f7d1336278d114ff431499b9c1 Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Sun, 28 Dec 2025 20:23:40 +0100 Subject: [PATCH] Remove obsolete 'Connect with Nostr' message from presentation page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations :** * Remove outdated message that appears after account creation/import * Clean up dead code and unused translation keys * Simplify presentation page UX now that key creation/import is available **Root causes :** * Message 'Connectez-vous avec Nostr pour créer votre article de présentation' was displayed even when account exists * NotConnected component and translation keys were no longer needed after implementing key creation/import **Correctifs :** * Removed NotConnected component and its message * Removed presentation.notConnected translation keys from all locale files * Simplified display to show ConnectButton directly when no pubkey is available * Added auto-loading of pubkey when account exists but pubkey not yet loaded **Evolutions :** * Presentation form now displays immediately when account exists (even if not unlocked) * Better UX: users can see the form and will get error message if they try to publish without unlocking **Page affectées :** * components/AuthorPresentationEditor.tsx * locales/fr.txt * locales/en.txt * public/locales/fr.txt * public/locales/en.txt --- components/AuthorPresentationEditor.tsx | 42 +++++++++++++------------ locales/en.txt | 1 - locales/fr.txt | 1 - public/locales/en.txt | 1 - public/locales/fr.txt | 1 - 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/components/AuthorPresentationEditor.tsx b/components/AuthorPresentationEditor.tsx index 6668518..d8e4b21 100644 --- a/components/AuthorPresentationEditor.tsx +++ b/components/AuthorPresentationEditor.tsx @@ -1,4 +1,4 @@ -import { useState, useCallback } from 'react' +import { useState, useCallback, useEffect, type FormEvent } from 'react' import { useNostrAuth } from '@/hooks/useNostrAuth' import { useAuthorPresentation } from '@/hooks/useAuthorPresentation' import { ArticleField } from './ArticleField' @@ -17,19 +17,6 @@ interface AuthorPresentationDraft { const ADDRESS_PATTERN = /^(1|3|bc1)[a-zA-Z0-9]{25,62}$/ -function NotConnected() { - return ( -
-
-

- {t('presentation.notConnected')} -

- -
-
- ) -} - function SuccessNotice() { return (
@@ -162,12 +149,12 @@ function PresentationForm({ validationError: string | null error: string | null loading: boolean - handleSubmit: (e: React.FormEvent) => Promise + handleSubmit: (e: FormEvent) => Promise userName: string }) { return (
{ + onSubmit={(e: FormEvent) => { void handleSubmit(e) }} className="border border-neon-cyan/20 rounded-lg p-6 bg-cyber-dark space-y-4" @@ -190,7 +177,7 @@ function useAuthorPresentationState(pubkey: string | null) { const [validationError, setValidationError] = useState(null) const handleSubmit = useCallback( - async (e: React.FormEvent) => { + async (e: FormEvent) => { e.preventDefault() const address = draft.mainnetAddress.trim() if (!ADDRESS_PATTERN.test(address)) { @@ -217,8 +204,14 @@ function AuthorPresentationFormView({ }) { const state = useAuthorPresentationState(pubkey) - if (!connected || !pubkey) { - return + if (!pubkey) { + return ( +
+
+ +
+
+ ) } if (state.success) { return @@ -240,7 +233,16 @@ function AuthorPresentationFormView({ ) } +function useAutoLoadPubkey(accountExists: boolean | null, pubkey: string | null, connect: () => Promise) { + useEffect(() => { + if (accountExists === true && !pubkey) { + void connect() + } + }, [accountExists, pubkey, connect]) +} + export function AuthorPresentationEditor() { - const { connected, pubkey, profile } = useNostrAuth() + const { connected, pubkey, profile, accountExists, connect } = useNostrAuth() + useAutoLoadPubkey(accountExists, pubkey ?? null, connect) return } diff --git a/locales/en.txt b/locales/en.txt index a23dbeb..b3a47f4 100644 --- a/locales/en.txt +++ b/locales/en.txt @@ -59,7 +59,6 @@ presentation.title=Create your presentation article presentation.description=This article is required to publish on zapwall.fr. It allows readers to know you and sponsor you. presentation.success=Presentation article created! presentation.successMessage=Your presentation article has been created successfully. You can now publish articles. -presentation.notConnected=Connect with Nostr to create your presentation article presentation.profileNote=This profile data is specific to zapwall.fr and may differ from your Nostr profile. presentation.field.picture=Profile picture presentation.field.picture.help=Profile image for your author page (max 5MB, formats: PNG, JPG, WebP) diff --git a/locales/fr.txt b/locales/fr.txt index 8a985d6..7a768f3 100644 --- a/locales/fr.txt +++ b/locales/fr.txt @@ -60,7 +60,6 @@ presentation.description=Cet article est obligatoire pour publier sur zapwall.fr presentation.profileNote=Les données de ce profil sont spécifiques à zapwall.fr et peuvent différer de votre profil Nostr. presentation.success=Article de présentation créé ! presentation.successMessage=Votre article de présentation a été créé avec succès. Vous pouvez maintenant publier des articles. -presentation.notConnected=Connectez-vous avec Nostr pour créer votre article de présentation # Filters filters.clear=Effacer tout diff --git a/public/locales/en.txt b/public/locales/en.txt index 7a77b5c..ed685b6 100644 --- a/public/locales/en.txt +++ b/public/locales/en.txt @@ -59,7 +59,6 @@ presentation.title=Create your presentation article presentation.description=This article is required to publish on zapwall.fr. It allows readers to know you and sponsor you. presentation.success=Presentation article created! presentation.successMessage=Your presentation article has been created successfully. You can now publish articles. -presentation.notConnected=Connect with Nostr to create your presentation article presentation.profileNote=This profile data is specific to zapwall.fr and may differ from your Nostr profile. presentation.field.picture=Profile picture presentation.field.picture.help=Profile image for your author page (max 5MB, formats: PNG, JPG, WebP) diff --git a/public/locales/fr.txt b/public/locales/fr.txt index 1f82caf..43d2f1b 100644 --- a/public/locales/fr.txt +++ b/public/locales/fr.txt @@ -59,7 +59,6 @@ presentation.title=Créer votre article de présentation presentation.description=Cet article est obligatoire pour publier sur zapwall.fr. Il permet aux lecteurs de vous connaître et de vous sponsoriser. presentation.success=Article de présentation créé ! presentation.successMessage=Votre article de présentation a été créé avec succès. Vous pouvez maintenant publier des articles. -presentation.notConnected=Connectez-vous avec Nostr pour créer votre article de présentation presentation.profileNote=Les données de ce profil sont spécifiques à zapwall.fr et peuvent différer de votre profil Nostr. presentation.field.picture=Photo de profil presentation.field.picture.help=Image de profil pour votre page auteur (max 5Mo, formats: PNG, JPG, WebP)