From 69afc6572903ae2cd72c26f46135573728a50036 Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Mon, 27 Nov 2023 13:37:47 -0500 Subject: [PATCH 1/7] TestFlight deployment --- CHANGELOG.md | 2 ++ Nos.xcodeproj/project.pbxproj | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec80f489..0f308a0db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1 (95)] - 2023-11-27Z + - Fixed a bug where a root note could be rendered as a reply - Added the option to copy the text content while browsing a note. - Fixed UI bugs when displaying the root note of replies. diff --git a/Nos.xcodeproj/project.pbxproj b/Nos.xcodeproj/project.pbxproj index e595c99ff..ed7b91d17 100644 --- a/Nos.xcodeproj/project.pbxproj +++ b/Nos.xcodeproj/project.pbxproj @@ -1963,7 +1963,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEVELOPMENT_TEAM = GZCZBKH7MY; GCC_OPTIMIZATION_LEVEL = s; GENERATE_INFOPLIST_FILE = YES; @@ -1984,7 +1984,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEVELOPMENT_TEAM = GZCZBKH7MY; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -2131,7 +2131,7 @@ CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Nos/Views/Preview Content\""; DEVELOPMENT_TEAM = GZCZBKH7MY; @@ -2182,7 +2182,7 @@ CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Nos/Views/Preview Content\""; DEVELOPMENT_TEAM = GZCZBKH7MY; @@ -2225,7 +2225,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GCC_OPTIMIZATION_LEVEL = 0; @@ -2251,7 +2251,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GENERATE_INFOPLIST_FILE = YES; @@ -2275,7 +2275,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GCC_OPTIMIZATION_LEVEL = 0; @@ -2300,7 +2300,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GENERATE_INFOPLIST_FILE = YES; From 695df2ff9a626c4bc8def6438dc255fc0340bb55 Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Mon, 27 Nov 2023 16:21:38 -0500 Subject: [PATCH 2/7] WIP fix reposts of reposts and parse repost content field --- Nos/Models/Event+CoreDataClass.swift | 36 ++++++++++++++++++++++++++++ Nos/Service/RelayService.swift | 18 +++++++------- Nos/Service/UNSAPI.swift | 2 +- Nos/Views/NoteButton.swift | 2 +- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/Nos/Models/Event+CoreDataClass.swift b/Nos/Models/Event+CoreDataClass.swift index 6491717c2..e84197fed 100644 --- a/Nos/Models/Event+CoreDataClass.swift +++ b/Nos/Models/Event+CoreDataClass.swift @@ -627,6 +627,9 @@ public class Event: NosManagedObject { case .mute: hydrateMuteList(from: jsonEvent, context: context) + case .repost: + parseContent(from: jsonEvent, context: context) + default: hydrateDefault(from: jsonEvent, context: context) } @@ -770,6 +773,22 @@ public class Event: NosManagedObject { } } + /// Tries to parse a new event out of the given jsonEvent's `content` field. + @discardableResult + func parseContent(from jsonEvent: JSONEvent, context: NSManagedObjectContext) -> Event? { + do { + if let contentData = jsonEvent.content.data(using: .utf8) { + let jsonEvent = try JSONDecoder().decode(JSONEvent.self, from: contentData) + return try Event().createIfNecessary(jsonEvent: jsonEvent, relay: nil, context: context) + } + } catch { + Log.error("Could not parse content for jsonEvent: \(jsonEvent)") + return nil + } + + return nil + } + // MARK: - Helpers var serializedEventForSigning: [Any?] { @@ -1018,6 +1037,23 @@ public class Event: NosManagedObject { return nil } + /// Returns the event this note is directly replying to, or nil if there isn't one. + func repostedNote() -> Event? { + if let reference = eventReferences.firstObject as? EventReference, + let repostedNote = reference.referencedEvent { + + if repostedNote.kind == EventKind.repost.rawValue { + // This is a repost of a repost. It's not valid according to NIP-18, but people are doing it so we + // are supporting it. + return repostedNote.repostedNote() + } + + return repostedNote + } + + return nil + } + /// This tracks which relays this event is deleted on. Hide posts with deletedOn.count > 0 func trackDelete(on relay: Relay, context: NSManagedObjectContext) throws { if EventKind(rawValue: kind) == .delete, let eTags = allTags as? [[String]] { diff --git a/Nos/Service/RelayService.swift b/Nos/Service/RelayService.swift index bfaed2a33..150a997f7 100644 --- a/Nos/Service/RelayService.swift +++ b/Nos/Service/RelayService.swift @@ -236,7 +236,7 @@ extension RelayService { // MARK: Parsing extension RelayService { - private func parseEOSE(from socket: WebSocketClient, responseArray: [Any]) async { + private func parseEOSE(from socket: WebSocketClient, responseArray: NSArray) async { guard responseArray.count > 1 else { return } @@ -250,14 +250,14 @@ extension RelayService { } } - private func queueEventForParsing(_ responseArray: [Any], _ socket: WebSocket) async { + private func queueEventForParsing(_ responseArray: NSArray, _ socket: WebSocket) async { guard responseArray.count >= 3 else { Log.error("Error: invalid EVENT response: \(responseArray)") return } - guard let eventJSON = responseArray[safe: 2] as? [String: Any], - let subscriptionID = responseArray[safe: 1] as? RelaySubscription.ID else { + guard let eventJSON = responseArray.object(at: 2) as? [String: Any], + let subscriptionID = responseArray.object(at: 1) as? RelaySubscription.ID else { Log.error("Error: invalid EVENT JSON: \(responseArray)") return } @@ -304,7 +304,7 @@ extension RelayService { } } - private func parseOK(_ responseArray: [Any], _ socket: WebSocket) async { + private func parseOK(_ responseArray: NSArray, _ socket: WebSocket) async { guard responseArray.count > 2 else { return } @@ -357,7 +357,7 @@ extension RelayService { throw EventError.utf8Encoding } let jsonResponse = try JSONSerialization.jsonObject(with: responseData) - guard let responseArray = jsonResponse as? [Any], + guard let responseArray = jsonResponse as? NSArray, let responseType = responseArray.first as? String else { print("Error: got unparseable response: \(response)") return @@ -367,7 +367,7 @@ extension RelayService { case "EVENT": await queueEventForParsing(responseArray, socket) case "NOTICE": - if responseArray[safe: 1] as? String == "rate limited" { + if responseArray.object(at: 1) as? String == "rate limited" { analytics.rateLimited(by: socket) } case "EOSE": @@ -382,9 +382,9 @@ extension RelayService { } } - func shouldParseEvent(responseArray: [Any], json eventJSON: [String: Any]) async -> Bool { + func shouldParseEvent(responseArray: NSArray, json eventJSON: [String: Any]) async -> Bool { // Drop out of network subscriptions if the filter has inNetwork == true - if let subscriptionID = responseArray[safe: 1] as? RelaySubscription.ID, + if let subscriptionID = responseArray.object(at: 1) as? RelaySubscription.ID, let authorKey = eventJSON[JSONEvent.CodingKeys.pubKey.rawValue] as? HexadecimalString, let subscription = await subscriptions.subscription(from: subscriptionID) { if subscription.filter.inNetwork { diff --git a/Nos/Service/UNSAPI.swift b/Nos/Service/UNSAPI.swift index 862700e0e..4a8f673aa 100644 --- a/Nos/Service/UNSAPI.swift +++ b/Nos/Service/UNSAPI.swift @@ -10,7 +10,7 @@ import Foundation import Logger import Dependencies -typealias JSONObject = [String: Any] +typealias JSONObject = [String: Any?] typealias UNSNameID = String struct UNSNameRecord: Identifiable, Equatable { diff --git a/Nos/Views/NoteButton.swift b/Nos/Views/NoteButton.swift index a42bf093c..4ede129f5 100644 --- a/Nos/Views/NoteButton.swift +++ b/Nos/Views/NoteButton.swift @@ -58,7 +58,7 @@ struct NoteButton: View { /// The note displayed in the note card. Could be different from `note` i.e. in the case of a repost. var displayedNote: Event { if note.kind == EventKind.repost.rawValue, - let repostedNote = note.referencedNote() { + let repostedNote = note.repostedNote() { return repostedNote } else { return note From 9dcb3ab8d05be507fa3fb58b5a8e554b0e218cbf Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Wed, 29 Nov 2023 16:30:56 -0500 Subject: [PATCH 3/7] Fix parsing of reposts --- Nos.xcodeproj/project.pbxproj | 6 ++- .../xcshareddata/swiftpm/Package.resolved | 46 +++++++++++------ Nos/Models/Event+CoreDataClass.swift | 14 +++--- Nos/Service/RelayService.swift | 2 +- NosTests/EventTests.swift | 50 +++++++++++++++++++ NosTests/Fixtures/sample_repost.json | 28 +++++++++++ 6 files changed, 122 insertions(+), 24 deletions(-) create mode 100644 NosTests/Fixtures/sample_repost.json diff --git a/Nos.xcodeproj/project.pbxproj b/Nos.xcodeproj/project.pbxproj index ed7b91d17..dc0d1b2b3 100644 --- a/Nos.xcodeproj/project.pbxproj +++ b/Nos.xcodeproj/project.pbxproj @@ -262,6 +262,7 @@ C9ADB13F29929F1F0075E7F8 /* String+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9ADB13729928CC30075E7F8 /* String+Hex.swift */; }; C9ADB14129951CB10075E7F8 /* NSManagedObject+Nos.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9ADB14029951CB10075E7F8 /* NSManagedObject+Nos.swift */; }; C9ADB14229951CB10075E7F8 /* NSManagedObject+Nos.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9ADB14029951CB10075E7F8 /* NSManagedObject+Nos.swift */; }; + C9B2BA0A2B17E356006B6977 /* sample_repost.json in Resources */ = {isa = PBXBuildFile; fileRef = C9B2BA092B17E356006B6977 /* sample_repost.json */; }; C9B678DB29EEBF3B00303F33 /* DependencyInjection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678DA29EEBF3B00303F33 /* DependencyInjection.swift */; }; C9B678DC29EEBF3B00303F33 /* DependencyInjection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678DA29EEBF3B00303F33 /* DependencyInjection.swift */; }; C9B678DE29EEC35B00303F33 /* Foundation+Sendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678DD29EEC35B00303F33 /* Foundation+Sendable.swift */; }; @@ -621,6 +622,7 @@ C9ADB13729928CC30075E7F8 /* String+Hex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Hex.swift"; sourceTree = ""; }; C9ADB13C29929B540075E7F8 /* Bech32.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bech32.swift; sourceTree = ""; }; C9ADB14029951CB10075E7F8 /* NSManagedObject+Nos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSManagedObject+Nos.swift"; sourceTree = ""; }; + C9B2BA092B17E356006B6977 /* sample_repost.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = sample_repost.json; sourceTree = ""; }; C9B678DA29EEBF3B00303F33 /* DependencyInjection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DependencyInjection.swift; sourceTree = ""; }; C9B678DD29EEC35B00303F33 /* Foundation+Sendable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Foundation+Sendable.swift"; sourceTree = ""; }; C9B678E029EEC41000303F33 /* SocialGraphCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialGraphCache.swift; sourceTree = ""; }; @@ -1037,8 +1039,9 @@ C9DEC0042989477A0078B43A /* Fixtures */ = { isa = PBXGroup; children = ( - CD27177529A7C8B200AE8888 /* sample_replies.json */, C9DEC005298947900078B43A /* sample_data.json */, + CD27177529A7C8B200AE8888 /* sample_replies.json */, + C9B2BA092B17E356006B6977 /* sample_repost.json */, C9ADB134299288230075E7F8 /* KeyFixture.swift */, C90B16B72AFED96300CB4B85 /* URLExtensionTests.swift */, ); @@ -1492,6 +1495,7 @@ C987F84529BA951E00B44E7A /* ClarityCity-ExtraBoldItalic.otf in Resources */, C987F84329BA951E00B44E7A /* ClarityCity-Black.otf in Resources */, C987F85329BA951E00B44E7A /* ClarityCity-Regular.otf in Resources */, + C9B2BA0A2B17E356006B6977 /* sample_repost.json in Resources */, C987F84729BA951E00B44E7A /* ClarityCity-Light.otf in Resources */, C987F83929BA951E00B44E7A /* ClarityCity-MediumItalic.otf in Resources */, C987F85129BA951E00B44E7A /* ClarityCity-ExtraLightItalic.otf in Resources */, diff --git a/Nos.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Nos.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f2326c090..87c879219 100644 --- a/Nos.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Nos.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SDWebImage/SDWebImage.git", "state" : { - "revision" : "36e484b317522667a4b2de9b50daaa01dfa30809", - "version" : "5.18.0" + "revision" : "1b9a2e902cbde5fdf362faa0f4fd76ea74d74305", + "version" : "5.18.5" } }, { @@ -95,8 +95,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SDWebImage/SDWebImageSwiftUI", "state" : { - "revision" : "e837c37d45449fbd3b4745c10c5b5274e73edead", - "version" : "2.2.3" + "revision" : "aee64ef39b570c44ccf0f884c440fc6494a23c76", + "version" : "2.2.5" } }, { @@ -113,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/getsentry/sentry-cocoa.git", "state" : { - "revision" : "d062d9b31ccabdec706134f2216476d1996caf11", - "version" : "8.10.0" + "revision" : "a3e15ba9fd6c8efc6515ad9d6f3337bb2dc2e1e3", + "version" : "8.17.0" } }, { @@ -158,8 +158,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections.git", "state" : { - "revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2", - "version" : "1.0.4" + "revision" : "a902f1823a7ff3c9ab2fba0f992396b948eda307", + "version" : "1.0.5" } }, { @@ -180,6 +180,15 @@ "version" : "0.1.4" } }, + { + "identity" : "swift-http-types", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-types", + "state" : { + "revision" : "99d066e29effa8845e4761dd3f2f831edfdf8925", + "version" : "1.0.0" + } + }, { "identity" : "swift-log", "kind" : "remoteSourceControl", @@ -194,8 +203,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "3db5c4aeee8100d2db6f1eaf3864afdad5dc68fd", - "version" : "2.59.0" + "revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c", + "version" : "2.62.0" } }, { @@ -203,8 +212,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "fb70a0f5e984f23be48b11b4f1909f3bee016178", - "version" : "1.19.1" + "revision" : "798c962495593a23fdea0c0c63fd55571d8dff51", + "version" : "1.20.0" + } + }, + { + "identity" : "swift-nio-http2", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-http2.git", + "state" : { + "revision" : "3bd9004b9d685ed6b629760fc84903e48efec806", + "version" : "1.29.0" } }, { @@ -221,8 +239,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-transport-services.git", "state" : { - "revision" : "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58", - "version" : "1.19.0" + "revision" : "ebf8b9c365a6ce043bf6e6326a04b15589bd285e", + "version" : "1.20.0" } }, { diff --git a/Nos/Models/Event+CoreDataClass.swift b/Nos/Models/Event+CoreDataClass.swift index e84197fed..044697014 100644 --- a/Nos/Models/Event+CoreDataClass.swift +++ b/Nos/Models/Event+CoreDataClass.swift @@ -628,6 +628,7 @@ public class Event: NosManagedObject { hydrateMuteList(from: jsonEvent, context: context) case .repost: + hydrateDefault(from: jsonEvent, context: context) parseContent(from: jsonEvent, context: context) default: @@ -1037,17 +1038,14 @@ public class Event: NosManagedObject { return nil } - /// Returns the event this note is directly replying to, or nil if there isn't one. + /// Returns the event this note is reposting, if this note is a kind 6 repost. func repostedNote() -> Event? { + guard kind == EventKind.repost.rawValue else { + return nil + } + if let reference = eventReferences.firstObject as? EventReference, let repostedNote = reference.referencedEvent { - - if repostedNote.kind == EventKind.repost.rawValue { - // This is a repost of a repost. It's not valid according to NIP-18, but people are doing it so we - // are supporting it. - return repostedNote.repostedNote() - } - return repostedNote } diff --git a/Nos/Service/RelayService.swift b/Nos/Service/RelayService.swift index 150a997f7..33508793c 100644 --- a/Nos/Service/RelayService.swift +++ b/Nos/Service/RelayService.swift @@ -358,7 +358,7 @@ extension RelayService { } let jsonResponse = try JSONSerialization.jsonObject(with: responseData) guard let responseArray = jsonResponse as? NSArray, - let responseType = responseArray.first as? String else { + let responseType = responseArray.firstObject as? String else { print("Error: got unparseable response: \(response)") return } diff --git a/NosTests/EventTests.swift b/NosTests/EventTests.swift index 2c051c76e..a4baf11a0 100644 --- a/NosTests/EventTests.swift +++ b/NosTests/EventTests.swift @@ -111,6 +111,25 @@ final class EventTests: XCTestCase { XCTAssertEqual(replies?.count, 2) } + func testParseRepost() throws { + // Arrange + let sampleData = try Data(contentsOf: Bundle.current.url(forResource: "sample_repost", withExtension: "json")!) + let sampleEventID = "f41e430f632b1e747da7efbb0ce11616876851e2fa3bbac440101c1b8a091152" + let repostedEventID = "f82507f7c770a39d0eabf276ced34fbd6a172be869bd3a3231c9c0272f405008" + let repostedEventContents = "#kraftwerk https://v.nostr.build/lx7e.mp4 " + let testContext = persistenceController.container.viewContext + + // Act + let events = try EventProcessor.parse(jsonData: sampleData, from: nil, in: persistenceController) + let sampleEvent = try XCTUnwrap(events.first(where: { $0.identifier == sampleEventID })) + + // Assert + XCTAssertEqual(sampleEvent.identifier, sampleEventID) + let repostedEvent = try XCTUnwrap(sampleEvent.repostedNote()) + XCTAssertEqual(repostedEvent.identifier, repostedEventID) + XCTAssertEqual(repostedEvent.content, repostedEventContents) + } + func testSerializedEventForSigning() throws { // Arrange let testContext = persistenceController.container.viewContext @@ -371,6 +390,37 @@ final class EventTests: XCTestCase { XCTAssertNil(testEvent.referencedNote()) } + + func testRepostedNote() throws { + let testContext = persistenceController.container.viewContext + let testEvent = try createTestEvent(in: testContext) + testEvent.kind = 6 + + let mention = try EventReference( + jsonTag: ["e", "646daa2f5d2d990dc98fb50a6ce8de65d77419cee689d7153c912175e85ca95d"], + context: testContext + ) + testEvent.addToEventReferences(mention) + + XCTAssertEqual( + testEvent.repostedNote()?.identifier, + "646daa2f5d2d990dc98fb50a6ce8de65d77419cee689d7153c912175e85ca95d" + ) + } + + func testRepostedNoteGivenNonRepost() throws { + let testContext = persistenceController.container.viewContext + let testEvent = try createTestEvent(in: testContext) + testEvent.kind = 1 + + let mention = try EventReference( + jsonTag: ["e", "646daa2f5d2d990dc98fb50a6ce8de65d77419cee689d7153c912175e85ca95d"], + context: testContext + ) + testEvent.addToEventReferences(mention) + + XCTAssertEqual(testEvent.repostedNote()?.identifier, nil) + } // MARK: - Helpers diff --git a/NosTests/Fixtures/sample_repost.json b/NosTests/Fixtures/sample_repost.json new file mode 100644 index 000000000..39924b779 --- /dev/null +++ b/NosTests/Fixtures/sample_repost.json @@ -0,0 +1,28 @@ +[ + { + "id" : "f41e430f632b1e747da7efbb0ce11616876851e2fa3bbac440101c1b8a091152", + "content" : "{\"sig\":\"c33f8ee08b47a862c159f09f75794369041b2d982b2e79762b9ed79fbb24e2801b9668b0bf60e7f8b01f9c514989e5e26ae2b205097f62b37aab838cb3783b8c\",\"pubkey\":\"76c71aae3a491f1d9eec47cba17e229cda4113a0bbb6e6ae1776d7643e29cafa\",\"kind\":1,\"id\":\"f82507f7c770a39d0eabf276ced34fbd6a172be869bd3a3231c9c0272f405008\",\"tags\":[[\"imeta\",\"url https:\\\/\\\/v.nostr.build\\\/lx7e.mp4\",\"blurhash eL2RZYkVVukUi|kBfjayfjfjQDaLoyafbtbXe:jbfQfRptkBV[f*jH\",\"dim 720x1280\"],[\"t\",\"kraftwerk\"],[\"r\",\"https:\\\/\\\/v.nostr.build\\\/lx7e.mp4\"]],\"content\":\"#kraftwerk https:\\\/\\\/v.nostr.build\\\/lx7e.mp4 \",\"created_at\":1701245356}", + "kind" : 6, + "tags" : [ + [ + "e", + "f82507f7c770a39d0eabf276ced34fbd6a172be869bd3a3231c9c0272f405008", + "wss:\/\/nostr.oxtr.dev", + "wss:\/\/nos.lol", + "wss:\/\/relay.damus.io", + "wss:\/\/relay.nostr.band", + "wss:\/\/relay.current.fyi", + "wss:\/\/relay.nostr.bg", + "wss:\/\/e.nos.lol", + "wss:\/\/nostr.fmt.wiz.biz" + ], + [ + "p", + "76c71aae3a491f1d9eec47cba17e229cda4113a0bbb6e6ae1776d7643e29cafa" + ] + ], + "sig" : "f9c1af62ad567c72a692a9881799724c4c94df0955c0ec1ae6322fc9f7468821390d5c45a73e544d79513ccc541d7f430fd4d29aa28426471f40895afcf46614", + "created_at" : 1701258681, + "pubkey" : "e731ca427c18059d66636ddfaeeeb15012bc2db3cdd27b9e4cade5057a6e82ed" + } +] From f8fa7e5931022d84bc2028afbe96c86aa8e0b746 Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Wed, 29 Nov 2023 16:34:40 -0500 Subject: [PATCH 4/7] Revert unecessary changes --- CHANGELOG.md | 7 ---- Nos.xcodeproj/project.pbxproj | 70 +++++++++------------------------- Nos/Service/RelayService.swift | 20 +++++----- Nos/Service/UNSAPI.swift | 2 +- 4 files changed, 28 insertions(+), 71 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d409c931..622d04d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Tapping on a tab bar icon can let you scroll to top. - -## [0.1 (95)] - 2023-11-27Z - -- Fixed a bug where a root note could be rendered as a reply -- Added the option to copy the text content while browsing a note. -- Fixed UI bugs when displaying the root note of replies. - Keep track of read stories. ## [0.1 (94)] - 2023-11-17Z diff --git a/Nos.xcodeproj/project.pbxproj b/Nos.xcodeproj/project.pbxproj index dc0d1b2b3..a87dc6949 100644 --- a/Nos.xcodeproj/project.pbxproj +++ b/Nos.xcodeproj/project.pbxproj @@ -83,6 +83,7 @@ C930055F2A6AF8320098CA9E /* LoadingContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C930055E2A6AF8320098CA9E /* LoadingContent.swift */; }; C93005602A6AF8320098CA9E /* LoadingContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C930055E2A6AF8320098CA9E /* LoadingContent.swift */; }; C931517D29B915AF00934506 /* StaggeredGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = C931517C29B915AF00934506 /* StaggeredGrid.swift */; }; + C9332C632ADECFA700AD7B0E /* StarscreamOld in Frameworks */ = {isa = PBXBuildFile; productRef = C9332C622ADECFA700AD7B0E /* StarscreamOld */; }; C9332C662ADED0D700AD7B0E /* StarscreamOld in Frameworks */ = {isa = PBXBuildFile; productRef = C9332C652ADED0D700AD7B0E /* StarscreamOld */; }; C936B4592A4C7B7C00DF1EB9 /* Nos.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = C936B4572A4C7B7C00DF1EB9 /* Nos.xcdatamodeld */; }; C936B45A2A4C7B7C00DF1EB9 /* Nos.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = C936B4572A4C7B7C00DF1EB9 /* Nos.xcdatamodeld */; }; @@ -262,7 +263,6 @@ C9ADB13F29929F1F0075E7F8 /* String+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9ADB13729928CC30075E7F8 /* String+Hex.swift */; }; C9ADB14129951CB10075E7F8 /* NSManagedObject+Nos.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9ADB14029951CB10075E7F8 /* NSManagedObject+Nos.swift */; }; C9ADB14229951CB10075E7F8 /* NSManagedObject+Nos.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9ADB14029951CB10075E7F8 /* NSManagedObject+Nos.swift */; }; - C9B2BA0A2B17E356006B6977 /* sample_repost.json in Resources */ = {isa = PBXBuildFile; fileRef = C9B2BA092B17E356006B6977 /* sample_repost.json */; }; C9B678DB29EEBF3B00303F33 /* DependencyInjection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678DA29EEBF3B00303F33 /* DependencyInjection.swift */; }; C9B678DC29EEBF3B00303F33 /* DependencyInjection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678DA29EEBF3B00303F33 /* DependencyInjection.swift */; }; C9B678DE29EEC35B00303F33 /* Foundation+Sendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678DD29EEC35B00303F33 /* Foundation+Sendable.swift */; }; @@ -271,11 +271,6 @@ C9B678E229EEC41000303F33 /* SocialGraphCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678E029EEC41000303F33 /* SocialGraphCache.swift */; }; C9B678E429EED2DC00303F33 /* SocialGraphTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678E329EED2DC00303F33 /* SocialGraphTests.swift */; }; C9B678E729F01A8500303F33 /* FullscreenProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B678E629F01A8500303F33 /* FullscreenProgressView.swift */; }; - C9B6AC412B14F07800C72EED /* Web3Wallet in Frameworks */ = {isa = PBXBuildFile; productRef = C9B6AC402B14F07800C72EED /* Web3Wallet */; }; - C9B6AC432B14F07E00C72EED /* Web3 in Frameworks */ = {isa = PBXBuildFile; productRef = C9B6AC422B14F07E00C72EED /* Web3 */; }; - C9B6AC452B14F08700C72EED /* WalletConnectModal in Frameworks */ = {isa = PBXBuildFile; productRef = C9B6AC442B14F08700C72EED /* WalletConnectModal */; }; - C9B6AC472B14F1A200C72EED /* WalletConnect in Frameworks */ = {isa = PBXBuildFile; productRef = C9B6AC462B14F1A200C72EED /* WalletConnect */; }; - C9B6AC492B14F1F400C72EED /* StarscreamOld in Frameworks */ = {isa = PBXBuildFile; productRef = C9B6AC482B14F1F400C72EED /* StarscreamOld */; }; C9B708BB2A13BE41006C613A /* NoteTextEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B708BA2A13BE41006C613A /* NoteTextEditor.swift */; }; C9B71DBE2A8E9BAD0031ED9F /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = C9B71DBD2A8E9BAD0031ED9F /* Sentry */; }; C9B71DC02A8E9BAD0031ED9F /* SentrySwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = C9B71DBF2A8E9BAD0031ED9F /* SentrySwiftUI */; }; @@ -622,7 +617,6 @@ C9ADB13729928CC30075E7F8 /* String+Hex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Hex.swift"; sourceTree = ""; }; C9ADB13C29929B540075E7F8 /* Bech32.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bech32.swift; sourceTree = ""; }; C9ADB14029951CB10075E7F8 /* NSManagedObject+Nos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSManagedObject+Nos.swift"; sourceTree = ""; }; - C9B2BA092B17E356006B6977 /* sample_repost.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = sample_repost.json; sourceTree = ""; }; C9B678DA29EEBF3B00303F33 /* DependencyInjection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DependencyInjection.swift; sourceTree = ""; }; C9B678DD29EEC35B00303F33 /* Foundation+Sendable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Foundation+Sendable.swift"; sourceTree = ""; }; C9B678E029EEC41000303F33 /* SocialGraphCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialGraphCache.swift; sourceTree = ""; }; @@ -741,6 +735,7 @@ C97797BC298AB1890046BD25 /* secp256k1 in Frameworks */, C9AA1BB42ABA3D5C00E8BD6D /* Web3Wallet in Frameworks */, C9B71DBE2A8E9BAD0031ED9F /* Sentry in Frameworks */, + C9332C632ADECFA700AD7B0E /* StarscreamOld in Frameworks */, C9646E9A29B79E04007239A4 /* Logger in Frameworks */, C9646EA729B7A3DD007239A4 /* Dependencies in Frameworks */, C9AA1BBC2ABB6E8900E8BD6D /* WalletConnectModal in Frameworks */, @@ -756,16 +751,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C9B6AC432B14F07E00C72EED /* Web3 in Frameworks */, C99DBF802A9E8BCF00F7068F /* SDWebImageSwiftUI in Frameworks */, C97797BF298ABE060046BD25 /* secp256k1 in Frameworks */, - C9B6AC412B14F07800C72EED /* Web3Wallet in Frameworks */, CDDA1F7B29A527650047ACD8 /* Starscream in Frameworks */, C9B71DC52A9008300031ED9F /* Sentry in Frameworks */, - C9B6AC452B14F08700C72EED /* WalletConnectModal in Frameworks */, C9646EA929B7A4F2007239A4 /* PostHog in Frameworks */, - C9B6AC472B14F1A200C72EED /* WalletConnect in Frameworks */, - C9B6AC492B14F1F400C72EED /* StarscreamOld in Frameworks */, C9646EAC29B7A520007239A4 /* Dependencies in Frameworks */, C905B0752A619367009B8A78 /* DequeModule in Frameworks */, C9646E9C29B79E4D007239A4 /* Logger in Frameworks */, @@ -1039,9 +1029,8 @@ C9DEC0042989477A0078B43A /* Fixtures */ = { isa = PBXGroup; children = ( - C9DEC005298947900078B43A /* sample_data.json */, CD27177529A7C8B200AE8888 /* sample_replies.json */, - C9B2BA092B17E356006B6977 /* sample_repost.json */, + C9DEC005298947900078B43A /* sample_data.json */, C9ADB134299288230075E7F8 /* KeyFixture.swift */, C90B16B72AFED96300CB4B85 /* URLExtensionTests.swift */, ); @@ -1242,6 +1231,7 @@ 2D06BB9C2AE249D70085F509 /* ThreadRootView.swift */, 3F60F42829B27D3E000D62C4 /* ThreadView.swift */, C9A2FCA12AE6FF360020A5C6 /* USBCBalanceBarButtonItem.swift */, + C913DA0D2AEB3265003BDD6D /* WarningView.swift */, C9CE5B132A0172CF008E198C /* WebView.swift */, C92F01502AC4D67B00972489 /* Form */, C9CFF6D02AB241EB00D4B368 /* Modifiers */, @@ -1311,6 +1301,7 @@ C9AA1BB32ABA3D5C00E8BD6D /* Web3Wallet */, C9AA1BB92ABB62EB00E8BD6D /* Web3 */, C9AA1BBB2ABB6E8900E8BD6D /* WalletConnectModal */, + C9332C622ADECFA700AD7B0E /* StarscreamOld */, C9332C652ADED0D700AD7B0E /* StarscreamOld */, ); productName = Nos; @@ -1342,11 +1333,6 @@ C905B0742A619367009B8A78 /* DequeModule */, C9B71DC42A9008300031ED9F /* Sentry */, C99DBF7F2A9E8BCF00F7068F /* SDWebImageSwiftUI */, - C9B6AC402B14F07800C72EED /* Web3Wallet */, - C9B6AC422B14F07E00C72EED /* Web3 */, - C9B6AC442B14F08700C72EED /* WalletConnectModal */, - C9B6AC462B14F1A200C72EED /* WalletConnect */, - C9B6AC482B14F1F400C72EED /* StarscreamOld */, ); productName = NosTests; productReference = C9DEBFE4298941020078B43A /* NosTests.xctest */; @@ -1495,7 +1481,6 @@ C987F84529BA951E00B44E7A /* ClarityCity-ExtraBoldItalic.otf in Resources */, C987F84329BA951E00B44E7A /* ClarityCity-Black.otf in Resources */, C987F85329BA951E00B44E7A /* ClarityCity-Regular.otf in Resources */, - C9B2BA0A2B17E356006B6977 /* sample_repost.json in Resources */, C987F84729BA951E00B44E7A /* ClarityCity-Light.otf in Resources */, C987F83929BA951E00B44E7A /* ClarityCity-MediumItalic.otf in Resources */, C987F85129BA951E00B44E7A /* ClarityCity-ExtraLightItalic.otf in Resources */, @@ -1967,7 +1952,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEVELOPMENT_TEAM = GZCZBKH7MY; GCC_OPTIMIZATION_LEVEL = s; GENERATE_INFOPLIST_FILE = YES; @@ -1988,7 +1973,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEVELOPMENT_TEAM = GZCZBKH7MY; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 16.2; @@ -2135,7 +2120,7 @@ CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Nos/Views/Preview Content\""; DEVELOPMENT_TEAM = GZCZBKH7MY; @@ -2186,7 +2171,7 @@ CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Nos/Views/Preview Content\""; DEVELOPMENT_TEAM = GZCZBKH7MY; @@ -2229,7 +2214,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GCC_OPTIMIZATION_LEVEL = 0; @@ -2255,7 +2240,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GENERATE_INFOPLIST_FILE = YES; @@ -2279,7 +2264,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GCC_OPTIMIZATION_LEVEL = 0; @@ -2304,7 +2289,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 94; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = GZCZBKH7MY; GENERATE_INFOPLIST_FILE = YES; @@ -2500,6 +2485,10 @@ package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections" */; productName = DequeModule; }; + C9332C622ADECFA700AD7B0E /* StarscreamOld */ = { + isa = XCSwiftPackageProductDependency; + productName = StarscreamOld; + }; C9332C652ADED0D700AD7B0E /* StarscreamOld */ = { isa = XCSwiftPackageProductDependency; productName = StarscreamOld; @@ -2594,31 +2583,6 @@ package = C95F0AC82ABA379700A0D9CE /* XCRemoteSwiftPackageReference "WalletConnectSwiftV2" */; productName = WalletConnectModal; }; - C9B6AC402B14F07800C72EED /* Web3Wallet */ = { - isa = XCSwiftPackageProductDependency; - package = C95F0AC82ABA379700A0D9CE /* XCRemoteSwiftPackageReference "WalletConnectSwiftV2" */; - productName = Web3Wallet; - }; - C9B6AC422B14F07E00C72EED /* Web3 */ = { - isa = XCSwiftPackageProductDependency; - package = C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3" */; - productName = Web3; - }; - C9B6AC442B14F08700C72EED /* WalletConnectModal */ = { - isa = XCSwiftPackageProductDependency; - package = C95F0AC82ABA379700A0D9CE /* XCRemoteSwiftPackageReference "WalletConnectSwiftV2" */; - productName = WalletConnectModal; - }; - C9B6AC462B14F1A200C72EED /* WalletConnect */ = { - isa = XCSwiftPackageProductDependency; - package = C95F0AC82ABA379700A0D9CE /* XCRemoteSwiftPackageReference "WalletConnectSwiftV2" */; - productName = WalletConnect; - }; - C9B6AC482B14F1F400C72EED /* StarscreamOld */ = { - isa = XCSwiftPackageProductDependency; - package = C9332C642ADED0D700AD7B0E /* XCLocalSwiftPackageReference "StarscreamOld" */; - productName = StarscreamOld; - }; C9B71DBD2A8E9BAD0031ED9F /* Sentry */ = { isa = XCSwiftPackageProductDependency; package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */; diff --git a/Nos/Service/RelayService.swift b/Nos/Service/RelayService.swift index 33508793c..bfaed2a33 100644 --- a/Nos/Service/RelayService.swift +++ b/Nos/Service/RelayService.swift @@ -236,7 +236,7 @@ extension RelayService { // MARK: Parsing extension RelayService { - private func parseEOSE(from socket: WebSocketClient, responseArray: NSArray) async { + private func parseEOSE(from socket: WebSocketClient, responseArray: [Any]) async { guard responseArray.count > 1 else { return } @@ -250,14 +250,14 @@ extension RelayService { } } - private func queueEventForParsing(_ responseArray: NSArray, _ socket: WebSocket) async { + private func queueEventForParsing(_ responseArray: [Any], _ socket: WebSocket) async { guard responseArray.count >= 3 else { Log.error("Error: invalid EVENT response: \(responseArray)") return } - guard let eventJSON = responseArray.object(at: 2) as? [String: Any], - let subscriptionID = responseArray.object(at: 1) as? RelaySubscription.ID else { + guard let eventJSON = responseArray[safe: 2] as? [String: Any], + let subscriptionID = responseArray[safe: 1] as? RelaySubscription.ID else { Log.error("Error: invalid EVENT JSON: \(responseArray)") return } @@ -304,7 +304,7 @@ extension RelayService { } } - private func parseOK(_ responseArray: NSArray, _ socket: WebSocket) async { + private func parseOK(_ responseArray: [Any], _ socket: WebSocket) async { guard responseArray.count > 2 else { return } @@ -357,8 +357,8 @@ extension RelayService { throw EventError.utf8Encoding } let jsonResponse = try JSONSerialization.jsonObject(with: responseData) - guard let responseArray = jsonResponse as? NSArray, - let responseType = responseArray.firstObject as? String else { + guard let responseArray = jsonResponse as? [Any], + let responseType = responseArray.first as? String else { print("Error: got unparseable response: \(response)") return } @@ -367,7 +367,7 @@ extension RelayService { case "EVENT": await queueEventForParsing(responseArray, socket) case "NOTICE": - if responseArray.object(at: 1) as? String == "rate limited" { + if responseArray[safe: 1] as? String == "rate limited" { analytics.rateLimited(by: socket) } case "EOSE": @@ -382,9 +382,9 @@ extension RelayService { } } - func shouldParseEvent(responseArray: NSArray, json eventJSON: [String: Any]) async -> Bool { + func shouldParseEvent(responseArray: [Any], json eventJSON: [String: Any]) async -> Bool { // Drop out of network subscriptions if the filter has inNetwork == true - if let subscriptionID = responseArray.object(at: 1) as? RelaySubscription.ID, + if let subscriptionID = responseArray[safe: 1] as? RelaySubscription.ID, let authorKey = eventJSON[JSONEvent.CodingKeys.pubKey.rawValue] as? HexadecimalString, let subscription = await subscriptions.subscription(from: subscriptionID) { if subscription.filter.inNetwork { diff --git a/Nos/Service/UNSAPI.swift b/Nos/Service/UNSAPI.swift index 4a8f673aa..862700e0e 100644 --- a/Nos/Service/UNSAPI.swift +++ b/Nos/Service/UNSAPI.swift @@ -10,7 +10,7 @@ import Foundation import Logger import Dependencies -typealias JSONObject = [String: Any?] +typealias JSONObject = [String: Any] typealias UNSNameID = String struct UNSNameRecord: Identifiable, Equatable { From ce9f934b5da1b233821eb1c08a609c7005b8717e Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Wed, 29 Nov 2023 16:35:19 -0500 Subject: [PATCH 5/7] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 622d04d8d..0e0dae051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Keep track of read stories. +- Fix an issue where reposts were not displaying correctly. ## [0.1 (94)] - 2023-11-17Z From 7ab39b1c3fb52d8f27ad2aa15a565a383393fed3 Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Wed, 29 Nov 2023 17:44:33 -0500 Subject: [PATCH 6/7] Fix tests --- Nos.xcodeproj/project.pbxproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Nos.xcodeproj/project.pbxproj b/Nos.xcodeproj/project.pbxproj index a87dc6949..001c8c353 100644 --- a/Nos.xcodeproj/project.pbxproj +++ b/Nos.xcodeproj/project.pbxproj @@ -110,6 +110,7 @@ C94A5E162A716A6D00B6EC5D /* EditableNoteText.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94A5E142A716A6D00B6EC5D /* EditableNoteText.swift */; }; C94A5E182A72C84200B6EC5D /* ReportCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94A5E172A72C84200B6EC5D /* ReportCategory.swift */; }; C94A5E192A72C84200B6EC5D /* ReportCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94A5E172A72C84200B6EC5D /* ReportCategory.swift */; }; + C94B2D182B17F5EC002104B6 /* sample_repost.json in Resources */ = {isa = PBXBuildFile; fileRef = C94B2D172B17F5EC002104B6 /* sample_repost.json */; }; C94C4CF32AD993CA00F801CA /* UNSErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94C4CF22AD993CA00F801CA /* UNSErrorView.swift */; }; C94D14812A12B3F70014C906 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94D14802A12B3F70014C906 /* SearchBar.swift */; }; C94D59AC2AE711A400295AE8 /* WalletConnectErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94D59AB2AE711A400295AE8 /* WalletConnectErrorView.swift */; }; @@ -516,6 +517,7 @@ C94437E529B0DB83004D8C86 /* NotificationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsView.swift; sourceTree = ""; }; C94A5E142A716A6D00B6EC5D /* EditableNoteText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditableNoteText.swift; sourceTree = ""; }; C94A5E172A72C84200B6EC5D /* ReportCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportCategory.swift; sourceTree = ""; }; + C94B2D172B17F5EC002104B6 /* sample_repost.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = sample_repost.json; sourceTree = ""; }; C94BC09A2A0AC74A0098F6F1 /* PreviewData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewData.swift; sourceTree = ""; }; C94C4CF22AD993CA00F801CA /* UNSErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UNSErrorView.swift; sourceTree = ""; }; C94D14802A12B3F70014C906 /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = ""; }; @@ -1029,6 +1031,7 @@ C9DEC0042989477A0078B43A /* Fixtures */ = { isa = PBXGroup; children = ( + C94B2D172B17F5EC002104B6 /* sample_repost.json */, CD27177529A7C8B200AE8888 /* sample_replies.json */, C9DEC005298947900078B43A /* sample_data.json */, C9ADB134299288230075E7F8 /* KeyFixture.swift */, @@ -1231,7 +1234,6 @@ 2D06BB9C2AE249D70085F509 /* ThreadRootView.swift */, 3F60F42829B27D3E000D62C4 /* ThreadView.swift */, C9A2FCA12AE6FF360020A5C6 /* USBCBalanceBarButtonItem.swift */, - C913DA0D2AEB3265003BDD6D /* WarningView.swift */, C9CE5B132A0172CF008E198C /* WebView.swift */, C92F01502AC4D67B00972489 /* Form */, C9CFF6D02AB241EB00D4B368 /* Modifiers */, @@ -1494,6 +1496,7 @@ C987F85529BA951E00B44E7A /* ClarityCity-Thin.otf in Resources */, C987F83F29BA951E00B44E7A /* ClarityCity-SemiBold.otf in Resources */, C9DEC006298947900078B43A /* sample_data.json in Resources */, + C94B2D182B17F5EC002104B6 /* sample_repost.json in Resources */, C987F84929BA951E00B44E7A /* ClarityCity-BlackItalic.otf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; From 7a396a0208b4189bda14a3941227e41ea44105bd Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Wed, 6 Dec 2023 17:21:24 -0500 Subject: [PATCH 7/7] Address PR feedback --- CHANGELOG.md | 4 ++++ Nos/Views/StoryNoteView.swift | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e0dae051..8a30e290d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Tapping on a tab bar icon can let you scroll to top. +- Fixed a bug where a root note could be rendered as a reply +- Added the option to copy the text content while browsing a note. +- Fixed UI bugs when displaying the root note of replies. - Keep track of read stories. - Fix an issue where reposts were not displaying correctly. diff --git a/Nos/Views/StoryNoteView.swift b/Nos/Views/StoryNoteView.swift index 8676c14b6..44b725916 100644 --- a/Nos/Views/StoryNoteView.swift +++ b/Nos/Views/StoryNoteView.swift @@ -95,7 +95,7 @@ struct StoryNoteView: View { if shouldShowSpacing { Spacer(minLength: 85) } - if note.kind == EventKind.repost.rawValue, let repostedNote = note.referencedNote() { + if note.kind == EventKind.repost.rawValue, let repostedNote = note.repostedNote() { Button { router.push(repostedNote) } label: {