Fix initial message decryption

This commit is contained in:
styppo 2023-01-24 16:30:53 +00:00
parent 0d9673ad3f
commit 02f0a13f2b
No known key found for this signature in database
GPG Key ID: 3AAA685C50724C28
3 changed files with 11 additions and 6 deletions

View File

@ -17,10 +17,6 @@ export default {
type: Object,
required: true,
},
sent: {
type: Boolean,
default: false,
},
},
setup() {
return {
@ -44,7 +40,9 @@ export default {
methods: {
async decrypt() {
try {
const counterparty = this.sent ? this.message.recipient : this.message.author
const counterparty = this.message.author === this.app.myPubkey
? this.message.recipient
: this.message.author
this.plaintext = await this.app.decryptMessage(counterparty, this.message.content)
this.message.cachePlaintext(this.plaintext)
} catch (e) {

View File

@ -158,6 +158,13 @@ export const useNostrStore = defineStore('nostr', {
limit: 50,
})
// Fetch our messages once.
this.fetch({
kinds: [EventKind.DM],
authors: [pubkey],
limit: 500,
})
const subs = []
// Subscribe to events created by us.

View File

@ -11,7 +11,7 @@
:sent="message.author === app.myPubkey"
:stamp="formatMessageDate(message.createdAt)"
>
<EncryptedMessage :message="message" :sent="message.author === app.myPubkey" />
<EncryptedMessage :message="message" />
</q-chat-message>
<p v-if="!conversation?.length" class="placeholder">
This is the beginning of your message history with <UserName :pubkey="counterparty" clickable />.