This commit is contained in:
padreug 2025-02-14 23:12:34 +01:00
parent d694f9b645
commit d27f66e95d
5 changed files with 230 additions and 162 deletions

View file

@ -86,7 +86,7 @@ import { useNostrStore } from '@/stores/nostr'
import { KeyRound, Copy, Check, Eye, EyeOff, Loader2 } from 'lucide-vue-next'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
import { CardDescription, CardTitle } from '@/components/ui/card'
import { isValidPrivateKey, formatPrivateKey } from '@/lib/nostr'
const { t } = useI18n()
@ -139,7 +139,7 @@ const generateKey = () => {
privkey.value = newKey
error.value = ''
showRecoveryMessage.value = true
showKey.value = true // Show the key when generated
showKey.value = false
} catch (err) {
console.error('Failed to generate key:', err)
error.value = t('login.error')

View file

@ -16,6 +16,7 @@ const input = ref('')
const isSending = ref(false)
const error = ref('')
const messagesEndRef = ref<HTMLDivElement | null>(null)
const isSubscribing = ref(false)
const SUPPORT_NPUB = import.meta.env.VITE_SUPPORT_NPUB
if (!SUPPORT_NPUB) {
@ -71,11 +72,22 @@ onMounted(async () => {
const supportPubkeyHex = npubToHex(SUPPORT_NPUB)
nostrStore.activeChat = supportPubkeyHex
await nostrStore.subscribeToMessages()
// Try to subscribe in the background
isSubscribing.value = true
nostrStore.subscribeToMessages()
.catch(err => {
console.debug('Support chat subscription error:', err)
// Continue anyway - messages will come through when connection succeeds
})
.finally(() => {
isSubscribing.value = false
})
scrollToBottom()
} catch (err) {
console.error('Failed to initialize support chat:', err)
error.value = 'Failed to connect to support. Please try again later.'
console.debug('Support chat setup error:', err)
// Continue anyway
}
})
@ -90,10 +102,13 @@ onUnmounted(() => {
watch(() => nostrStore.activeChat, async (newChat) => {
if (newChat) {
try {
isSubscribing.value = true
await nostrStore.subscribeToMessages()
} catch (err) {
console.error('Failed to subscribe to messages:', err)
error.value = 'Failed to connect to chat. Please try again later.'
console.debug('Chat subscription error:', err)
// Continue anyway
} finally {
isSubscribing.value = false
}
}
})
@ -235,6 +250,12 @@ const getMessageGroupClasses = (sent: boolean) => {
</Button>
</form>
</CardFooter>
<!-- Add loading indicator if needed -->
<div v-if="isSubscribing" class="absolute top-4 right-4 flex items-center gap-2 text-sm text-muted-foreground">
<div class="h-2 w-2 rounded-full bg-primary animate-pulse"></div>
Connecting...
</div>
</Card>
</template>