-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Hide quoted or reposted notes from people whom the user has muted. (
#1216) Summary ------- This patch fixes the issue where the user might see notes from users that they have muted, if such note has been reposted or quoted. Furthermore, this patch introduces some improvements on some of the associated views, making them more reusable. Testing of the fix ------------------ **PASS** **Device:** iPhone 14 Pro simulator **iOS:** 17.0 **Damus:** This commit **Test steps:** 1. Create two test accounts (if not created already). We will use test account "A". Test account "B" is an external test account 2. Make some notes from test account "B" (if non existent) 3. Switch to account "A" 4. Under test account "A", follow account "B" 5. Repost a note from account "B", and quote another note from account "B" 6. Access "account B"'s timeline. Repost and quoted note should all be visible. Layout should look as usual 7. Click on the reposted note. Should appear and it should look normal 8. Click on the note with the quote. Should appear and it should look normal 9. Click on the quoted note. Should appear and it should look normal 10. Now mute account "B" 12. Go back to account "A"'s timeline 13. Repost should appear, but the reposted content should be hidden behind a mute box. Clicking on show/hide should show or hide muted content 14. Note with quoted content should appear, but the quoted content should be hidden behind a mute box. Clicking on show/hide should work as expected 15. Make sure that the layout in steps 13 and 14 look good. 16. Click on the repost to access the thread view. Should be muted as expected. 17. Add a comment to the repost. Comment should appear even if the mute box hides the main note 18. Click on the note with quote to open its thread view. Comments should appear, main note should appear, but quoted content should be behind the mute box 19. Under account "B", add a comment to the quoted notes 20. Under account "A", check in the thread view that "B"'s reply is behind a mute box 21. Reply to the note with the quote. Check that the note appears correctly and that quoted content is behind the mute box (in the post composer view) 22. Find on Nostr a post where one of the replies contains a quoted note. Mute the user of the quoted content, and check that quoted content is now in a mute box Smoke sanity test ----------------- **PASS** **Device:** iPhone 14 pro simulator **iOS:** 16.4 **Test steps:** Browse a timeline filled with real notes and comments. Go through different notes and threads, mute some users, just to make sure nothing else appears obsviously broken. Other notes ----------- I removed this code: ``` .frame(maxWidth: .infinity, minHeight: PFP_SIZE) ``` from `EventShell`, because it was causing the layout to break on "threaded" style event view with muted quoted content (e.g. in a reply with quoted content). The line of code dates back to `495859e07f`, but I am not sure why this line existed in the first place, or if removing it has any negative impact. Closes: #1216 Changelog-Fixed: Hide quoted or reposted notes from people whom the user has muted. (#1216) Signed-off-by: Daniel D’Aquino <[email protected]> Reviewed-by: William Casarin <[email protected]> Signed-off-by: William Casarin <[email protected]>
- Loading branch information
1 parent
46382ae
commit 66310a1
Showing
9 changed files
with
232 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// EventLoaderView.swift | ||
// damus | ||
// | ||
// Created by Daniel D’Aquino on 2023-09-27. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// This view handles the loading logic for Nostr events, so that you can easily use views that require `NostrEvent`, even if you only have a `NoteId` | ||
struct EventLoaderView<Content: View>: View { | ||
let damus_state: DamusState | ||
let event_id: NoteId | ||
@State var event: NostrEvent? | ||
@State var subscription_uuid: String = UUID().description | ||
let content: (NostrEvent) -> Content | ||
|
||
init(damus_state: DamusState, event_id: NoteId, @ViewBuilder content: @escaping (NostrEvent) -> Content) { | ||
self.damus_state = damus_state | ||
self.event_id = event_id | ||
self.content = content | ||
let event = damus_state.events.lookup(event_id) | ||
_event = State(initialValue: event) | ||
} | ||
|
||
func unsubscribe() { | ||
damus_state.pool.unsubscribe(sub_id: subscription_uuid) | ||
} | ||
|
||
func subscribe(filters: [NostrFilter]) { | ||
damus_state.pool.register_handler(sub_id: subscription_uuid, handler: handle_event) | ||
damus_state.pool.send(.subscribe(.init(filters: filters, sub_id: subscription_uuid))) | ||
} | ||
|
||
func handle_event(relay_id: String, ev: NostrConnectionEvent) { | ||
guard case .nostr_event(let nostr_response) = ev else { | ||
return | ||
} | ||
|
||
guard case .event(let id, let nostr_event) = nostr_response else { | ||
return | ||
} | ||
|
||
guard id == subscription_uuid else { | ||
return | ||
} | ||
|
||
if event != nil { | ||
return | ||
} | ||
|
||
event = nostr_event | ||
|
||
unsubscribe() | ||
} | ||
|
||
func load() { | ||
subscribe(filters: [ | ||
NostrFilter(ids: [self.event_id], limit: 1) | ||
]) | ||
} | ||
|
||
var body: some View { | ||
VStack { | ||
if let event { | ||
self.content(event) | ||
} else { | ||
ProgressView().padding() | ||
} | ||
} | ||
.onAppear { | ||
guard event == nil else { | ||
return | ||
} | ||
self.load() | ||
} | ||
} | ||
} | ||
|
||
|
||
struct EventLoaderView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
EventLoaderView(damus_state: test_damus_state, event_id: test_note.id) { event in | ||
EventView(damus: test_damus_state, event: event) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.