Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve DM design #816

Closed
wants to merge 18 commits into from
Closed

Conversation

suhailsaqan
Copy link
Member

@suhailsaqan suhailsaqan commented Mar 28, 2023

IMG_9165.MP4

@suhailsaqan suhailsaqan marked this pull request as draft March 28, 2023 21:33
@suhailsaqan
Copy link
Member Author

Need to fix the input field to expand to multiple lines.

@jb55
Copy link
Collaborator

jb55 commented Apr 4, 2023

looks nice!

@suhailsaqan suhailsaqan marked this pull request as ready for review April 22, 2023 23:44
@suhailsaqan
Copy link
Member Author

Need to fix issue where it displays image twice.

damus/Views/DMChatView.swift Outdated Show resolved Hide resolved
damus/Views/DMView.swift Outdated Show resolved Hide resolved
@jb55
Copy link
Collaborator

jb55 commented Apr 24, 2023

try this for the separate functions:

From ef7ec18e6a88a5b632fd19a568cced244aa5df59 Mon Sep 17 00:00:00 2001
From: William Casarin <[email protected]>
Date: Mon, 24 Apr 2023 16:54:23 -0700
Subject: [PATCH] suggestion

---
 damus/Nostr/NostrEvent.swift | 32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift
index 8e187579..bf569826 100644
--- a/damus/Nostr/NostrEvent.swift
+++ b/damus/Nostr/NostrEvent.swift
@@ -1040,37 +1040,21 @@ func first_eref_mention(ev: NostrEvent, privkey: String?) -> Mention? {
 }
 
 func separate_images(ev: NostrEvent, privkey: String?) -> [URL]? {
-    let urlBlocks = ev.blocks(privkey).filter { block in
-        switch block {
-        case .url:
-            return true
-        default:
-            return false
-        }
-    }.compactMap { block in
-        if case .url(let url) = block {
-            return url
-        } else {
-            return nil
+    let urlBlocks: [URL] = ev.blocks(privkey).reduce(into: []) { urls, block in
+        guard case .url(let url) = block else {
+            return
         }
+        urls.append(url)
     }
     return urlBlocks.isEmpty ? nil : urlBlocks
 }
 
 func separate_invoices(ev: NostrEvent, privkey: String?) -> [Invoice]? {
-    let invoiceBlocks = ev.blocks(privkey).filter { block in
-        switch block {
-        case .invoice:
-            return true
-        default:
-            return false
-        }
-    }.compactMap { block in
-        if case .invoice(let invoice) = block {
-            return invoice
-        } else {
-            return nil
+    let invoiceBlocks: [Invoice] = ev.blocks(privkey).reduce(into: []) { invoices, block in
+        guard case .invoice(let invoice) = block else {
+            return
         }
+        invoices.append(invoice)
     }
     return invoiceBlocks.isEmpty ? nil : invoiceBlocks
 }
-- 
2.39.2 (Apple Git-143)

@suhailsaqan suhailsaqan force-pushed the improve-dms branch 3 times, most recently from 9f93bfe to bfb8eac Compare August 8, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants