mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-09 16:08:47 +01:00
Swiftformat
This commit is contained in:
parent
383eb84e98
commit
4e77669181
@ -247,7 +247,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func statusDidAppear(status: Models.Status) { }
|
func statusDidAppear(status _: Models.Status) {}
|
||||||
|
|
||||||
func statusDidDisappear(status: Status) { }
|
func statusDidDisappear(status _: Status) {}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||||||
mentionString += "@\(mention.acct)"
|
mentionString += "@\(mention.acct)"
|
||||||
}
|
}
|
||||||
if !mentionString.isEmpty {
|
if !mentionString.isEmpty {
|
||||||
mentionString += " "
|
mentionString += " "
|
||||||
}
|
}
|
||||||
replyToStatus = status
|
replyToStatus = status
|
||||||
visibility = status.visibility
|
visibility = status.visibility
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import SwiftUI
|
|
||||||
import Models
|
import Models
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class PendingStatusesObserver: ObservableObject {
|
class PendingStatusesObserver: ObservableObject {
|
||||||
@ -18,12 +18,12 @@ class PendingStatusesObserver: ObservableObject {
|
|||||||
|
|
||||||
func removeStatus(status: Status) {
|
func removeStatus(status: Status) {
|
||||||
if !disableUpdate, let index = pendingStatuses.firstIndex(of: status.id) {
|
if !disableUpdate, let index = pendingStatuses.firstIndex(of: status.id) {
|
||||||
pendingStatuses.removeSubrange(index...(pendingStatuses.count - 1))
|
pendingStatuses.removeSubrange(index ... (pendingStatuses.count - 1))
|
||||||
feedbackGenerator.impactOccurred()
|
feedbackGenerator.impactOccurred()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init() { }
|
init() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PendingStatusesObserverView: View {
|
struct PendingStatusesObserverView: View {
|
||||||
@ -32,7 +32,7 @@ struct PendingStatusesObserverView: View {
|
|||||||
if observer.pendingStatusesCount > 0 {
|
if observer.pendingStatusesCount > 0 {
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 6) {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button { } label: {
|
Button {} label: {
|
||||||
Text("\(observer.pendingStatusesCount)")
|
Text("\(observer.pendingStatusesCount)")
|
||||||
}
|
}
|
||||||
.buttonStyle(.bordered)
|
.buttonStyle(.bordered)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import SwiftUI
|
|
||||||
import Models
|
import Models
|
||||||
import Network
|
import Network
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
actor TimelineCache {
|
actor TimelineCache {
|
||||||
static let shared: TimelineCache = .init()
|
static let shared: TimelineCache = .init()
|
||||||
@ -10,7 +10,7 @@ actor TimelineCache {
|
|||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
func set(statuses: [Status], client: Client) {
|
func set(statuses: [Status], client: Client) {
|
||||||
memoryCache[client] = statuses.prefix(upTo: min(100, (statuses.count - 1))).map{ $0 }
|
memoryCache[client] = statuses.prefix(upTo: min(100, statuses.count - 1)).map { $0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStatuses(for client: Client) -> [Status]? {
|
func getStatuses(for client: Client) -> [Status]? {
|
||||||
|
@ -156,7 +156,7 @@ public struct TimelineView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var scrollToTopView: some View {
|
private var scrollToTopView: some View {
|
||||||
HStack{ EmptyView() }
|
HStack { EmptyView() }
|
||||||
.listRowBackground(theme.primaryBackgroundColor)
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
.listRowSeparator(.hidden)
|
.listRowSeparator(.hidden)
|
||||||
.listRowInsets(.init())
|
.listRowInsets(.init())
|
||||||
|
@ -57,7 +57,6 @@ class TimelineViewModel: ObservableObject {
|
|||||||
client?.server ?? "Error"
|
client?.server ?? "Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func fetchTag(id: String) async {
|
func fetchTag(id: String) async {
|
||||||
guard let client else { return }
|
guard let client else { return }
|
||||||
do {
|
do {
|
||||||
@ -65,7 +64,7 @@ class TimelineViewModel: ObservableObject {
|
|||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleEvent(event: any StreamEvent, currentAccount: CurrentAccount) {
|
func handleEvent(event: any StreamEvent, currentAccount _: CurrentAccount) {
|
||||||
if let event = event as? StreamEventUpdate,
|
if let event = event as? StreamEventUpdate,
|
||||||
canStreamEvents,
|
canStreamEvents,
|
||||||
pendingStatusesEnabled,
|
pendingStatusesEnabled,
|
||||||
@ -91,6 +90,7 @@ class TimelineViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Cache
|
// MARK: - Cache
|
||||||
|
|
||||||
extension TimelineViewModel {
|
extension TimelineViewModel {
|
||||||
private func cache(statuses: [Status]) async {
|
private func cache(statuses: [Status]) async {
|
||||||
if let client {
|
if let client {
|
||||||
@ -107,6 +107,7 @@ extension TimelineViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - StatusesFetcher
|
// MARK: - StatusesFetcher
|
||||||
|
|
||||||
extension TimelineViewModel: StatusesFetcher {
|
extension TimelineViewModel: StatusesFetcher {
|
||||||
func fetchStatuses() async {
|
func fetchStatuses() async {
|
||||||
guard let client else { return }
|
guard let client else { return }
|
||||||
@ -152,7 +153,7 @@ extension TimelineViewModel: StatusesFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch pages from the top most status of the tomeline.
|
// Fetch pages from the top most status of the tomeline.
|
||||||
private func fetchNewPagesFrom(latestStatus: Status, client: Client) async throws {
|
private func fetchNewPagesFrom(latestStatus: Status, client _: Client) async throws {
|
||||||
canStreamEvents = false
|
canStreamEvents = false
|
||||||
var newStatuses: [Status] = await fetchNewPages(minId: latestStatus.id, maxPages: 10)
|
var newStatuses: [Status] = await fetchNewPages(minId: latestStatus.id, maxPages: 10)
|
||||||
|
|
||||||
@ -187,7 +188,7 @@ extension TimelineViewModel: StatusesFetcher {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Append new statuses in the timeline indicator.
|
// Append new statuses in the timeline indicator.
|
||||||
pendingStatusesObserver.pendingStatuses.insert(contentsOf: newStatuses.map{ $0.id }, at: 0)
|
pendingStatusesObserver.pendingStatuses.insert(contentsOf: newStatuses.map { $0.id }, at: 0)
|
||||||
pendingStatusesObserver.feedbackGenerator.impactOccurred()
|
pendingStatusesObserver.feedbackGenerator.impactOccurred()
|
||||||
|
|
||||||
// High chance the user is scrolled to the top.
|
// High chance the user is scrolled to the top.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user