From 32055c65123537d3c4afd6944b9f5afa78e91cca Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Fri, 22 Mar 2024 17:42:54 -0400 Subject: [PATCH 1/3] Fix bug where loading less than a page of data in PagedNoteDataSource would cause no further pages to be loaded --- Nos.xcodeproj/project.pbxproj | 114 ++++++++++-------- Nos/Controller/PagedNoteDataSource.swift | 20 ++- Nos/Views/Profile/ProfileFeedType.swift | 26 ++++ Nos/Views/{ => Profile}/ProfileHeader.swift | 12 +- .../ProfileKnownFollowersView.swift | 0 .../ProfileSocialStatsView.swift | 0 Nos/Views/{ => Profile}/ProfileTab.swift | 0 Nos/Views/{ => Profile}/ProfileView.swift | 13 +- 8 files changed, 111 insertions(+), 74 deletions(-) create mode 100644 Nos/Views/Profile/ProfileFeedType.swift rename Nos/Views/{ => Profile}/ProfileHeader.swift (96%) rename Nos/Views/{ => Profile}/ProfileKnownFollowersView.swift (100%) rename Nos/Views/{ => Profile}/ProfileSocialStatsView.swift (100%) rename Nos/Views/{ => Profile}/ProfileTab.swift (100%) rename Nos/Views/{ => Profile}/ProfileView.swift (95%) diff --git a/Nos.xcodeproj/project.pbxproj b/Nos.xcodeproj/project.pbxproj index b0b0d5fd8..efd327bd3 100644 --- a/Nos.xcodeproj/project.pbxproj +++ b/Nos.xcodeproj/project.pbxproj @@ -88,6 +88,7 @@ A3B943D7299D6DB700A15A08 /* Follow+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B943D4299D514800A15A08 /* Follow+CoreDataClass.swift */; }; A3B943D8299D758F00A15A08 /* KeyChain.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B943CE299AE00100A15A08 /* KeyChain.swift */; }; C900385F2B6195C60080CC4F /* FollowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C900385E2B6195C60080CC4F /* FollowTests.swift */; }; + C9032C2E2BAE31ED001F4EC6 /* ProfileFeedType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9032C2D2BAE31ED001F4EC6 /* ProfileFeedType.swift */; }; C905B0752A619367009B8A78 /* DequeModule in Frameworks */ = {isa = PBXBuildFile; productRef = C905B0742A619367009B8A78 /* DequeModule */; }; C905B0772A619E99009B8A78 /* LinkPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = C905B0762A619E99009B8A78 /* LinkPreview.swift */; }; C90862BE29E9804B00C35A71 /* NosPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C90862BD29E9804B00C35A71 /* NosPerformanceTests.swift */; }; @@ -540,6 +541,7 @@ A3B943CE299AE00100A15A08 /* KeyChain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyChain.swift; sourceTree = ""; }; A3B943D4299D514800A15A08 /* Follow+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Follow+CoreDataClass.swift"; sourceTree = ""; }; C900385E2B6195C60080CC4F /* FollowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowTests.swift; sourceTree = ""; }; + C9032C2D2BAE31ED001F4EC6 /* ProfileFeedType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileFeedType.swift; sourceTree = ""; }; C905B0762A619E99009B8A78 /* LinkPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkPreview.swift; sourceTree = ""; }; C905EA342A3360FE006F1E99 /* StagingSecrets.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = StagingSecrets.xcconfig; path = Nos/Assets/StagingSecrets.xcconfig; sourceTree = SOURCE_ROOT; }; C90862BB29E9804B00C35A71 /* NosPerformanceTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NosPerformanceTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -946,6 +948,19 @@ path = Components; sourceTree = ""; }; + C9032C2C2BAE31DA001F4EC6 /* Profile */ = { + isa = PBXGroup; + children = ( + C95D689E299E6B4100429F86 /* ProfileHeader.swift */, + 5B834F662A83FB5C000C1432 /* ProfileKnownFollowersView.swift */, + 5B834F682A83FC7F000C1432 /* ProfileSocialStatsView.swift */, + C987F81C29BA6D9A00B44E7A /* ProfileTab.swift */, + C95D68AC299E721700429F86 /* ProfileView.swift */, + C9032C2D2BAE31ED001F4EC6 /* ProfileFeedType.swift */, + ); + path = Profile; + sourceTree = ""; + }; C905EA362A33620A006F1E99 /* UNS */ = { isa = PBXGroup; children = ( @@ -1374,11 +1389,6 @@ C95D68A4299E6E1E00429F86 /* PlaceholderModifier.swift */, C9E37E112A1E7EC5003D4B0A /* PreviewContainer.swift */, C94BC09A2A0AC74A0098F6F1 /* PreviewData.swift */, - C95D689E299E6B4100429F86 /* ProfileHeader.swift */, - 5B834F662A83FB5C000C1432 /* ProfileKnownFollowersView.swift */, - 5B834F682A83FC7F000C1432 /* ProfileSocialStatsView.swift */, - C987F81C29BA6D9A00B44E7A /* ProfileTab.swift */, - C95D68AC299E721700429F86 /* ProfileView.swift */, 5BFF66B32A58853D00AA79DD /* PublishedEventsView.swift */, C97A1C8729E45B3C009D9E8D /* RawEventView.swift */, C9A25B3C29F174D200B39534 /* ReadabilityPadding.swift */, @@ -1415,6 +1425,7 @@ C9EE3E652A053CF1008A7491 /* New Note */, 3FB5E64F299D288E00386527 /* Onboarding */, C9DEBFDD298941020078B43A /* Preview Content */, + C9032C2C2BAE31DA001F4EC6 /* Profile */, 5B79F5E92B97B5D7002DA9BE /* ProfileEdit */, C905EA362A33620A006F1E99 /* UNS */, C9F2046E2ADEDDCA0029A858 /* USBC */, @@ -1596,22 +1607,22 @@ ); mainGroup = C9DEBFC5298941000078B43A; packageReferences = ( - C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream.git" */, - C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1.swift" */, + C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream" */, + C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1" */, C94D855D29914D2300749478 /* XCRemoteSwiftPackageReference "swiftui-navigation" */, - C9ADB139299299570075E7F8 /* XCRemoteSwiftPackageReference "bech32.git" */, + C9ADB139299299570075E7F8 /* XCRemoteSwiftPackageReference "bech32" */, C9646E9829B79E04007239A4 /* XCRemoteSwiftPackageReference "logger-ios" */, - C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios.git" */, + C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios" */, C9646EA529B7A3DD007239A4 /* XCRemoteSwiftPackageReference "swift-dependencies" */, - C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections.git" */, - C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa.git" */, + C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections" */, + C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */, C99DBF7C2A9E81CF00F7068F /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */, C9B737702AB24D5F00398BE7 /* XCRemoteSwiftPackageReference "SwiftGenPlugin" */, C95F0AC82ABA379700A0D9CE /* XCRemoteSwiftPackageReference "WalletConnectSwiftV2" */, - C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3.swift" */, + C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3" */, C9332C642ADED0D700AD7B0E /* XCLocalSwiftPackageReference "StarscreamOld" */, C91565BF2B2368FA0068EECA /* XCRemoteSwiftPackageReference "ViewInspector" */, - 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin.git" */, + 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin" */, ); productRefGroup = C9DEBFCF298941000078B43A /* Products */; projectDirPath = ""; @@ -1915,6 +1926,7 @@ C9F0BB6929A5039D000547FC /* Int+Bool.swift in Sources */, DC5F203F2A6AE24200F8D73F /* ImagePickerButton.swift in Sources */, 5B79F5EB2B97B5E9002DA9BE /* ConfirmUsernameDeletionSheet.swift in Sources */, + C9032C2E2BAE31ED001F4EC6 /* ProfileFeedType.swift in Sources */, C981E2DD2AC610D600FBF4F6 /* UNSStepImage.swift in Sources */, C9CDBBA429A8FA2900C555C7 /* GoldenPostView.swift in Sources */, C92F01582AC4D6F700972489 /* NosTextField.swift in Sources */, @@ -2106,11 +2118,11 @@ /* Begin PBXTargetDependency section */ 3AD3185D2B294E9000026B07 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - productRef = 3AD3185C2B294E9000026B07 /* plugin:XCStringsToolPlugin */; + productRef = 3AD3185C2B294E9000026B07 /* XCStringsToolPlugin */; }; 3AEABEF32B2BF806001BC933 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - productRef = 3AEABEF22B2BF806001BC933 /* plugin:XCStringsToolPlugin */; + productRef = 3AEABEF22B2BF806001BC933 /* XCStringsToolPlugin */; }; C90862C229E9804B00C35A71 /* PBXTargetDependency */ = { isa = PBXTargetDependency; @@ -2119,11 +2131,11 @@ }; C9A6C7442AD83F7A001F9500 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - productRef = C9A6C7432AD83F7A001F9500 /* plugin:SwiftGenPlugin */; + productRef = C9A6C7432AD83F7A001F9500 /* SwiftGenPlugin */; }; C9D573402AB24A3700E06BB4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - productRef = C9D5733F2AB24A3700E06BB4 /* plugin:SwiftGenPlugin */; + productRef = C9D5733F2AB24A3700E06BB4 /* SwiftGenPlugin */; }; C9DEBFE6298941020078B43A /* PBXTargetDependency */ = { isa = PBXTargetDependency; @@ -2566,7 +2578,7 @@ /* End XCLocalSwiftPackageReference section */ /* Begin XCRemoteSwiftPackageReference section */ - 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin.git" */ = { + 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/liamnichols/xcstrings-tool-plugin.git"; requirement = { @@ -2606,7 +2618,7 @@ minimumVersion = 1.1.0; }; }; - C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios.git" */ = { + C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/PostHog/posthog-ios.git"; requirement = { @@ -2622,7 +2634,7 @@ minimumVersion = 0.1.4; }; }; - C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections.git" */ = { + C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/apple/swift-collections.git"; requirement = { @@ -2630,7 +2642,7 @@ minimumVersion = 1.0.0; }; }; - C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1.swift" */ = { + C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/GigaBitcoin/secp256k1.swift"; requirement = { @@ -2646,7 +2658,7 @@ minimumVersion = 2.0.0; }; }; - C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3.swift" */ = { + C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Boilertalk/Web3.swift"; requirement = { @@ -2654,7 +2666,7 @@ minimumVersion = 0.8.4; }; }; - C9ADB139299299570075E7F8 /* XCRemoteSwiftPackageReference "bech32.git" */ = { + C9ADB139299299570075E7F8 /* XCRemoteSwiftPackageReference "bech32" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/0xdeadp00l/bech32.git"; requirement = { @@ -2662,7 +2674,7 @@ kind = branch; }; }; - C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa.git" */ = { + C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/getsentry/sentry-cocoa.git"; requirement = { @@ -2686,7 +2698,7 @@ minimumVersion = 6.6.2; }; }; - C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream.git" */ = { + C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/daltoniam/Starscream.git"; requirement = { @@ -2697,19 +2709,19 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 3AD3185C2B294E9000026B07 /* plugin:XCStringsToolPlugin */ = { + 3AD3185C2B294E9000026B07 /* XCStringsToolPlugin */ = { isa = XCSwiftPackageProductDependency; - package = 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin.git" */; + package = 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin" */; productName = "plugin:XCStringsToolPlugin"; }; - 3AEABEF22B2BF806001BC933 /* plugin:XCStringsToolPlugin */ = { + 3AEABEF22B2BF806001BC933 /* XCStringsToolPlugin */ = { isa = XCSwiftPackageProductDependency; - package = 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin.git" */; + package = 3AD3185B2B294E6200026B07 /* XCRemoteSwiftPackageReference "xcstrings-tool-plugin" */; productName = "plugin:XCStringsToolPlugin"; }; C905B0742A619367009B8A78 /* DequeModule */ = { isa = XCSwiftPackageProductDependency; - package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections.git" */; + package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections" */; productName = DequeModule; }; C91565C02B2368FA0068EECA /* ViewInspector */ = { @@ -2732,7 +2744,7 @@ }; C94824492B32364900005B36 /* Web3 */ = { isa = XCSwiftPackageProductDependency; - package = C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3.swift" */; + package = C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3" */; productName = Web3; }; C94D855E29914D2300749478 /* SwiftUINavigation */ = { @@ -2757,7 +2769,7 @@ }; C9646EA329B7A24A007239A4 /* PostHog */ = { isa = XCSwiftPackageProductDependency; - package = C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios.git" */; + package = C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios" */; productName = PostHog; }; C9646EA629B7A3DD007239A4 /* Dependencies */ = { @@ -2767,7 +2779,7 @@ }; C9646EA829B7A4F2007239A4 /* PostHog */ = { isa = XCSwiftPackageProductDependency; - package = C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios.git" */; + package = C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios" */; productName = PostHog; }; C9646EAB29B7A520007239A4 /* Dependencies */ = { @@ -2777,17 +2789,17 @@ }; C96CB98B2A6040C500498C4E /* DequeModule */ = { isa = XCSwiftPackageProductDependency; - package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections.git" */; + package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections" */; productName = DequeModule; }; C97797BB298AB1890046BD25 /* secp256k1 */ = { isa = XCSwiftPackageProductDependency; - package = C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1.swift" */; + package = C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1" */; productName = secp256k1; }; C97797BE298ABE060046BD25 /* secp256k1 */ = { isa = XCSwiftPackageProductDependency; - package = C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1.swift" */; + package = C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1" */; productName = secp256k1; }; C99DBF7D2A9E81CF00F7068F /* SDWebImageSwiftUI */ = { @@ -2805,7 +2817,7 @@ package = C99DBF7C2A9E81CF00F7068F /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */; productName = SDWebImageSwiftUI; }; - C9A6C7432AD83F7A001F9500 /* plugin:SwiftGenPlugin */ = { + C9A6C7432AD83F7A001F9500 /* SwiftGenPlugin */ = { isa = XCSwiftPackageProductDependency; package = C9B737702AB24D5F00398BE7 /* XCRemoteSwiftPackageReference "SwiftGenPlugin" */; productName = "plugin:SwiftGenPlugin"; @@ -2817,7 +2829,7 @@ }; C9AA1BB92ABB62EB00E8BD6D /* Web3 */ = { isa = XCSwiftPackageProductDependency; - package = C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3.swift" */; + package = C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3" */; productName = Web3; }; C9AA1BBB2ABB6E8900E8BD6D /* WalletConnectModal */ = { @@ -2827,17 +2839,17 @@ }; C9B71DBD2A8E9BAD0031ED9F /* Sentry */ = { isa = XCSwiftPackageProductDependency; - package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa.git" */; + package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */; productName = Sentry; }; C9B71DBF2A8E9BAD0031ED9F /* SentrySwiftUI */ = { isa = XCSwiftPackageProductDependency; - package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa.git" */; + package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */; productName = SentrySwiftUI; }; C9B71DC42A9008300031ED9F /* Sentry */ = { isa = XCSwiftPackageProductDependency; - package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa.git" */; + package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */; productName = Sentry; }; C9BA85902B23628300AFC2C3 /* Logger */ = { @@ -2857,12 +2869,12 @@ }; C9BA85962B23638700AFC2C3 /* Starscream */ = { isa = XCSwiftPackageProductDependency; - package = C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream.git" */; + package = C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream" */; productName = Starscream; }; C9BA85982B23638700AFC2C3 /* secp256k1 */ = { isa = XCSwiftPackageProductDependency; - package = C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1.swift" */; + package = C97797BA298AB1890046BD25 /* XCRemoteSwiftPackageReference "secp256k1" */; productName = secp256k1; }; C9BA859A2B23638700AFC2C3 /* SwiftUINavigation */ = { @@ -2872,17 +2884,17 @@ }; C9BA859C2B23638700AFC2C3 /* PostHog */ = { isa = XCSwiftPackageProductDependency; - package = C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios.git" */; + package = C9646EA229B7A24A007239A4 /* XCRemoteSwiftPackageReference "posthog-ios" */; productName = PostHog; }; C9BA859E2B23638700AFC2C3 /* DequeModule */ = { isa = XCSwiftPackageProductDependency; - package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections.git" */; + package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections" */; productName = DequeModule; }; C9BA85A02B23638700AFC2C3 /* SentrySwiftUI */ = { isa = XCSwiftPackageProductDependency; - package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa.git" */; + package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */; productName = SentrySwiftUI; }; C9BA85A22B23638700AFC2C3 /* WalletConnect */ = { @@ -2892,7 +2904,7 @@ }; C9BA85A42B23638700AFC2C3 /* Web3 */ = { isa = XCSwiftPackageProductDependency; - package = C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3.swift" */; + package = C9AA1BB82ABB62EB00E8BD6D /* XCRemoteSwiftPackageReference "Web3" */; productName = Web3; }; C9BA85A62B23638700AFC2C3 /* StarscreamOld */ = { @@ -2907,22 +2919,22 @@ }; C9BA85AA2B2363CA00AFC2C3 /* Sentry */ = { isa = XCSwiftPackageProductDependency; - package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa.git" */; + package = C9B71DBC2A8E9BAD0031ED9F /* XCRemoteSwiftPackageReference "sentry-cocoa" */; productName = Sentry; }; - C9D5733F2AB24A3700E06BB4 /* plugin:SwiftGenPlugin */ = { + C9D5733F2AB24A3700E06BB4 /* SwiftGenPlugin */ = { isa = XCSwiftPackageProductDependency; package = C9C8450C2AB249DB00654BC1 /* XCRemoteSwiftPackageReference "SwiftGenPlugin" */; productName = "plugin:SwiftGenPlugin"; }; C9DEC067298965270078B43A /* Starscream */ = { isa = XCSwiftPackageProductDependency; - package = C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream.git" */; + package = C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream" */; productName = Starscream; }; CDDA1F7A29A527650047ACD8 /* Starscream */ = { isa = XCSwiftPackageProductDependency; - package = C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream.git" */; + package = C9DEC066298965270078B43A /* XCRemoteSwiftPackageReference "Starscream" */; productName = Starscream; }; CDDA1F7C29A527650047ACD8 /* SwiftUINavigation */ = { diff --git a/Nos/Controller/PagedNoteDataSource.swift b/Nos/Controller/PagedNoteDataSource.swift index 3a5154d2e..9b0174737 100644 --- a/Nos/Controller/PagedNoteDataSource.swift +++ b/Nos/Controller/PagedNoteDataSource.swift @@ -16,7 +16,7 @@ class PagedNoteDataSource: NSObject, UICol private var context: NSManagedObjectContext private var header: () -> Header private var emptyPlaceholder: () -> EmptyPlaceholder - let pageSize = 10 + let pageSize = 20 // We intentionally generate unique IDs for cell reuse to get around // [this issue](https://github.com/planetary-social/nos/issues/873) @@ -94,9 +94,7 @@ class PagedNoteDataSource: NSObject, UICol _ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath ) -> UICollectionViewCell { - if indexPath.row.isMultiple(of: pageSize) { - pager?.loadMore() - } + loadMoreIfNeeded(for: indexPath) let note = fetchedResultsController.object(at: indexPath) @@ -166,6 +164,20 @@ class PagedNoteDataSource: NSObject, UICol } } + // MARK: - Loading data + + /// Instructs the pager to load more data if we are getting close to the end of the object in the list. + /// - Parameter indexPath: the indexPath last loaded by the collection view. + func loadMoreIfNeeded(for indexPath: IndexPath) { + let lastPageIndex = (fetchedResultsController.fetchedObjects?.count ?? 0) - pageSize + if indexPath.row > lastPageIndex { + // we are at the end of the list, load aggressively + pager?.loadMore() + } else if indexPath.row.isMultiple(of: pageSize / 2) { + pager?.loadMore() + } + } + // MARK: - NSFetchedResultsControllerDelegate private var insertedIndexes = [IndexPath]() diff --git a/Nos/Views/Profile/ProfileFeedType.swift b/Nos/Views/Profile/ProfileFeedType.swift new file mode 100644 index 000000000..f697d9a70 --- /dev/null +++ b/Nos/Views/Profile/ProfileFeedType.swift @@ -0,0 +1,26 @@ +import CoreData + +/// An enumeration of the different feed algorithms the user can choose to view on the Profile screen. +enum ProfileFeedType { + case activity + case notes + + func databaseFilter(author: Author) -> NSFetchRequest { + author.allPostsRequest(onlyRootPosts: self == .notes) + } + + func relayFilter(author: Author) -> Filter { + var kinds: [EventKind] + switch self { + case .activity: + kinds = [.text, .delete, .repost, .longFormContent] + case .notes: + kinds = [.text, .delete] + } + + return Filter( + authorKeys: [author.hexadecimalPublicKey ?? "error"], + kinds: kinds + ) + } +} diff --git a/Nos/Views/ProfileHeader.swift b/Nos/Views/Profile/ProfileHeader.swift similarity index 96% rename from Nos/Views/ProfileHeader.swift rename to Nos/Views/Profile/ProfileHeader.swift index 722758f93..d6305c03a 100644 --- a/Nos/Views/ProfileHeader.swift +++ b/Nos/Views/Profile/ProfileHeader.swift @@ -6,7 +6,7 @@ struct ProfileHeader: View { @ObservedObject var author: Author @Environment(CurrentUser.self) private var currentUser - @Binding private var selectedTab: ProfileHeaderTab + @Binding private var selectedTab: ProfileFeedType var followsRequest: FetchRequest var followsResult: FetchedResults { followsRequest.wrappedValue } @@ -20,15 +20,7 @@ struct ProfileHeader: View { @EnvironmentObject private var router: Router - enum ProfileHeaderTab { - case activity - case notes - func request(author: Author) -> NSFetchRequest { - author.allPostsRequest(onlyRootPosts: self == .notes) - } - } - - init(author: Author, selectedTab: Binding) { + init(author: Author, selectedTab: Binding) { self.author = author self.followsRequest = FetchRequest(fetchRequest: Follow.followsRequest(sources: [author])) self.followersRequest = FetchRequest(fetchRequest: Follow.followsRequest(destination: [author])) diff --git a/Nos/Views/ProfileKnownFollowersView.swift b/Nos/Views/Profile/ProfileKnownFollowersView.swift similarity index 100% rename from Nos/Views/ProfileKnownFollowersView.swift rename to Nos/Views/Profile/ProfileKnownFollowersView.swift diff --git a/Nos/Views/ProfileSocialStatsView.swift b/Nos/Views/Profile/ProfileSocialStatsView.swift similarity index 100% rename from Nos/Views/ProfileSocialStatsView.swift rename to Nos/Views/Profile/ProfileSocialStatsView.swift diff --git a/Nos/Views/ProfileTab.swift b/Nos/Views/Profile/ProfileTab.swift similarity index 100% rename from Nos/Views/ProfileTab.swift rename to Nos/Views/Profile/ProfileTab.swift diff --git a/Nos/Views/ProfileView.swift b/Nos/Views/Profile/ProfileView.swift similarity index 95% rename from Nos/Views/ProfileView.swift rename to Nos/Views/Profile/ProfileView.swift index 45dacc6db..6cd60f584 100644 --- a/Nos/Views/ProfileView.swift +++ b/Nos/Views/Profile/ProfileView.swift @@ -23,7 +23,7 @@ struct ProfileView: View { @State private var usbcBalanceTimer: Timer? @State private var relaySubscriptions = SubscriptionCancellables() - @State private var selectedTab: ProfileHeader.ProfileHeaderTab = .notes + @State private var selectedTab: ProfileFeedType = .notes @State private var alert: AlertState? @@ -84,14 +84,9 @@ struct ProfileView: View { var body: some View { VStack(spacing: 0) { VStack { - let profileNotesFilter = Filter( - authorKeys: [author.hexadecimalPublicKey ?? "error"], - kinds: [.text, .delete, .repost, .longFormContent] - ) - PagedNoteListView( - databaseFilter: selectedTab.request(author: author), - relayFilter: profileNotesFilter, + databaseFilter: selectedTab.databaseFilter(author: author), + relayFilter: selectedTab.relayFilter(author: author), context: viewContext, tab: .profile, header: { @@ -108,7 +103,7 @@ struct ProfileView: View { .frame(minHeight: 300) }, onRefresh: { - selectedTab.request(author: author) + selectedTab.databaseFilter(author: author) } ) .padding(0) From a21044b16aa2163a55f57c1674ce3d58e1d38ce5 Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Mon, 25 Mar 2024 10:15:20 -0400 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d316fa10a..31ab1bd2a 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] - Added a new UI for replying to messages that allows attaching images and setting an expiration date. +- Fixed an issue where Profile pages could display little or no content. ## [0.1.7] - 2024-03-21Z From 5b60a08f3e9d90d5340365bc834571439622ebbc Mon Sep 17 00:00:00 2001 From: Matthew Lorentz Date: Mon, 25 Mar 2024 10:17:00 -0400 Subject: [PATCH 3/3] Rename variable --- Nos/Controller/PagedNoteDataSource.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nos/Controller/PagedNoteDataSource.swift b/Nos/Controller/PagedNoteDataSource.swift index 9b0174737..d2fb1333c 100644 --- a/Nos/Controller/PagedNoteDataSource.swift +++ b/Nos/Controller/PagedNoteDataSource.swift @@ -169,8 +169,8 @@ class PagedNoteDataSource: NSObject, UICol /// Instructs the pager to load more data if we are getting close to the end of the object in the list. /// - Parameter indexPath: the indexPath last loaded by the collection view. func loadMoreIfNeeded(for indexPath: IndexPath) { - let lastPageIndex = (fetchedResultsController.fetchedObjects?.count ?? 0) - pageSize - if indexPath.row > lastPageIndex { + let lastPageStartIndex = (fetchedResultsController.fetchedObjects?.count ?? 0) - pageSize + if indexPath.row > lastPageStartIndex { // we are at the end of the list, load aggressively pager?.loadMore() } else if indexPath.row.isMultiple(of: pageSize / 2) {