Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
lbrndnr committed Mar 21, 2024
1 parent 9d1fde9 commit d1f7553
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Nuage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -513,7 +513,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.0.7;
MARKETING_VERSION = 0.0.8;
PRODUCT_BUNDLE_IDENTIFIER = ch.laurinbrandner.nuage;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -541,7 +541,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.0.7;
MARKETING_VERSION = 0.0.8;
PRODUCT_BUNDLE_IDENTIFIER = ch.laurinbrandner.nuage;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
35 changes: 23 additions & 12 deletions Nuage/Views/InfiniteView/PageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ private let initialPageSubscription = 0
struct PageView<Element: Decodable&Identifiable, ContentView: View>: View {

var elements: [Element] {
return pages.map { $0.collection }
.reduce([], +)
return pages?.map { $0.collection }
.reduce([], +) ?? []
}
@State private var pages = [Page<Element>]()
@State private var pages: [Page<Element>]?

private var publisher: AnyPublisher<Page<Element>, Error>
@State private var subscriptions = [Int: AnyCancellable]()
Expand All @@ -28,19 +28,30 @@ struct PageView<Element: Decodable&Identifiable, ContentView: View>: View {

var body: some View {
Group {
if elements.isEmpty {
if let pages = pages {
if pages.isEmpty {
Text("Empty")
.font(.title2)
.foregroundColor(.secondary)
}
else {
content(elements, getNextPage)
}
}
else {
ProgressView()
.progressViewStyle(.circular)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
else {
content(elements, getNextPage)
}
}
.onAppear {
publisher.receive(on: RunLoop.main)
.sink(receiveCompletion: { _ in }, receiveValue: { page in
pages.append(page)
.sink(receiveCompletion: { completion in
if case .failure(_) = completion {
pages = []
}
}, receiveValue: { page in
pages = [page]
})
.store(in: &subscriptions, key: initialPageSubscription)
}
Expand All @@ -55,16 +66,16 @@ struct PageView<Element: Decodable&Identifiable, ContentView: View>: View {
private func getNextPage() {
guard subscriptions[elements.count] == nil else { return }

let currentPagePublisher = pages.publisher
let currentPagePublisher = (pages ?? []).publisher
.last()
.mapError{ $0 as Error }
.mapError { $0 as Error }

publisher.merge(with: currentPagePublisher)
.first()
.flatMap { SoundCloud.shared.get(next: $0) }
.receive(on: RunLoop.main)
.sink(receiveCompletion: { _ in }, receiveValue: { page in
pages.append(page)
pages?.append(page)
})
.store(in: &subscriptions, key: elements.count)
}
Expand Down

0 comments on commit d1f7553

Please sign in to comment.