Skip to content

Commit d1f7553

Browse files
committed
Bump version
1 parent 9d1fde9 commit d1f7553

2 files changed

Lines changed: 26 additions & 15 deletions

File tree

Nuage.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 53;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -513,7 +513,7 @@
513513
"@executable_path/../Frameworks",
514514
);
515515
MACOSX_DEPLOYMENT_TARGET = 13.0;
516-
MARKETING_VERSION = 0.0.7;
516+
MARKETING_VERSION = 0.0.8;
517517
PRODUCT_BUNDLE_IDENTIFIER = ch.laurinbrandner.nuage;
518518
PRODUCT_NAME = "$(TARGET_NAME)";
519519
SWIFT_VERSION = 5.0;
@@ -541,7 +541,7 @@
541541
"@executable_path/../Frameworks",
542542
);
543543
MACOSX_DEPLOYMENT_TARGET = 13.0;
544-
MARKETING_VERSION = 0.0.7;
544+
MARKETING_VERSION = 0.0.8;
545545
PRODUCT_BUNDLE_IDENTIFIER = ch.laurinbrandner.nuage;
546546
PRODUCT_NAME = "$(TARGET_NAME)";
547547
SWIFT_VERSION = 5.0;

Nuage/Views/InfiniteView/PageView.swift

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ private let initialPageSubscription = 0
1616
struct PageView<Element: Decodable&Identifiable, ContentView: View>: View {
1717

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

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

2929
var body: some View {
3030
Group {
31-
if elements.isEmpty {
31+
if let pages = pages {
32+
if pages.isEmpty {
33+
Text("Empty")
34+
.font(.title2)
35+
.foregroundColor(.secondary)
36+
}
37+
else {
38+
content(elements, getNextPage)
39+
}
40+
}
41+
else {
3242
ProgressView()
3343
.progressViewStyle(.circular)
3444
.frame(maxWidth: .infinity, maxHeight: .infinity)
3545
}
36-
else {
37-
content(elements, getNextPage)
38-
}
3946
}
4047
.onAppear {
4148
publisher.receive(on: RunLoop.main)
42-
.sink(receiveCompletion: { _ in }, receiveValue: { page in
43-
pages.append(page)
49+
.sink(receiveCompletion: { completion in
50+
if case .failure(_) = completion {
51+
pages = []
52+
}
53+
}, receiveValue: { page in
54+
pages = [page]
4455
})
4556
.store(in: &subscriptions, key: initialPageSubscription)
4657
}
@@ -55,16 +66,16 @@ struct PageView<Element: Decodable&Identifiable, ContentView: View>: View {
5566
private func getNextPage() {
5667
guard subscriptions[elements.count] == nil else { return }
5768

58-
let currentPagePublisher = pages.publisher
69+
let currentPagePublisher = (pages ?? []).publisher
5970
.last()
60-
.mapError{ $0 as Error }
71+
.mapError { $0 as Error }
6172

6273
publisher.merge(with: currentPagePublisher)
6374
.first()
6475
.flatMap { SoundCloud.shared.get(next: $0) }
6576
.receive(on: RunLoop.main)
6677
.sink(receiveCompletion: { _ in }, receiveValue: { page in
67-
pages.append(page)
78+
pages?.append(page)
6879
})
6980
.store(in: &subscriptions, key: elements.count)
7081
}

0 commit comments

Comments
 (0)