Show "New Post 💊" if new posts (IOS-234)
This commit is contained in:
parent
6f58c277c7
commit
527d250024
|
@ -318,6 +318,20 @@ extension HomeTimelineViewController {
|
||||||
self.timelinePillCenterXAnchor = timelinePillCenterXAnchor
|
self.timelinePillCenterXAnchor = timelinePillCenterXAnchor
|
||||||
self.timelinePillVisibleTopAnchor = timelinePillVisibleTopAnchor
|
self.timelinePillVisibleTopAnchor = timelinePillVisibleTopAnchor
|
||||||
self.timelinePillHiddenTopAnchor = timelinePillHiddenTopAnchor
|
self.timelinePillHiddenTopAnchor = timelinePillHiddenTopAnchor
|
||||||
|
|
||||||
|
viewModel?.hasNewPosts
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink(receiveValue: { [weak self] hasNewPosts in
|
||||||
|
guard let self else { return }
|
||||||
|
|
||||||
|
if hasNewPosts {
|
||||||
|
self.timelinePill.update(with: .newPosts)
|
||||||
|
self.showTimelinePill()
|
||||||
|
} else {
|
||||||
|
self.hideTimelinePill()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.store(in: &disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
|
@ -471,16 +485,18 @@ extension HomeTimelineViewController {
|
||||||
|
|
||||||
@objc private func timelinePillPressed(_ sender: TimelineStatusPill) {
|
@objc private func timelinePillPressed(_ sender: TimelineStatusPill) {
|
||||||
guard let reason = sender.reason else { return }
|
guard let reason = sender.reason else { return }
|
||||||
|
|
||||||
switch reason {
|
switch reason {
|
||||||
case .newPosts:
|
case .newPosts:
|
||||||
print("Bring me to the new posts and disappear")
|
scrollToTop(animated: true)
|
||||||
|
viewModel?.hasNewPosts.value = false
|
||||||
case .postSent:
|
case .postSent:
|
||||||
print("Bring me to my post and disappear")
|
print("Bring me to my post and disappear")
|
||||||
case .offline:
|
case .offline:
|
||||||
print("Just disappear")
|
hideTimelinePill()
|
||||||
}
|
}
|
||||||
|
|
||||||
hideTimelinePill()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func showTimelinePill() {
|
private func showTimelinePill() {
|
||||||
|
|
|
@ -160,6 +160,10 @@ extension HomeTimelineViewModel.LoadLatestState {
|
||||||
.impactOccurred()
|
.impactOccurred()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if newStatuses.isNotEmpty {
|
||||||
|
viewModel.hasNewPosts.value = true
|
||||||
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
await enter(state: Idle.self)
|
await enter(state: Idle.self)
|
||||||
viewModel.didLoadLatest.send()
|
viewModel.didLoadLatest.send()
|
||||||
|
|
|
@ -33,6 +33,7 @@ final class HomeTimelineViewModel: NSObject {
|
||||||
@Published var scrollPositionRecord: ScrollPositionRecord? = nil
|
@Published var scrollPositionRecord: ScrollPositionRecord? = nil
|
||||||
@Published var displaySettingBarButtonItem = true
|
@Published var displaySettingBarButtonItem = true
|
||||||
@Published var hasPendingStatusEditReload = false
|
@Published var hasPendingStatusEditReload = false
|
||||||
|
var hasNewPosts = CurrentValueSubject<Bool, Never>(false)
|
||||||
var timelineContext: MastodonFeed.Kind.TimelineContext = .home
|
var timelineContext: MastodonFeed.Kind.TimelineContext = .home
|
||||||
|
|
||||||
weak var tableView: UITableView?
|
weak var tableView: UITableView?
|
||||||
|
|
|
@ -71,5 +71,4 @@ class TimelineStatusPill: UIButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue