From d27f66e95d1b8288fda014fab7b11abdb712033f Mon Sep 17 00:00:00 2001 From: padreug Date: Fri, 14 Feb 2025 23:12:34 +0100 Subject: [PATCH] updates --- dev-dist/sw.js | 2 +- src/components/Login.vue | 4 +- src/components/SupportChat.vue | 31 ++- src/pages/Support.vue | 18 +- src/stores/nostr.ts | 337 ++++++++++++++++++--------------- 5 files changed, 230 insertions(+), 162 deletions(-) diff --git a/dev-dist/sw.js b/dev-dist/sw.js index f51d9ea..40d995c 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -79,7 +79,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict'; */ workbox.precacheAndRoute([{ "url": "index.html", - "revision": "0.dc5rn1lchj8" + "revision": "0.36o4mscev7" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/src/components/Login.vue b/src/components/Login.vue index e8b83fb..9546958 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -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') diff --git a/src/components/SupportChat.vue b/src/components/SupportChat.vue index e09473c..2e873d1 100644 --- a/src/components/SupportChat.vue +++ b/src/components/SupportChat.vue @@ -16,6 +16,7 @@ const input = ref('') const isSending = ref(false) const error = ref('') const messagesEndRef = ref(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) => { + + +
+
+ Connecting... +
diff --git a/src/pages/Support.vue b/src/pages/Support.vue index 7e88978..cc6a48f 100644 --- a/src/pages/Support.vue +++ b/src/pages/Support.vue @@ -1,14 +1,15 @@ @@ -20,6 +21,13 @@ if (!nostrStore.isLoggedIn) { + + + + + + +