mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
Add back posts streaming behind a setting, default to off
This commit is contained in:
parent
7eeaf4d902
commit
db7155423a
4 changed files with 50 additions and 3 deletions
|
@ -39,6 +39,7 @@ struct SettingsTabs: View {
|
||||||
accountsSection
|
accountsSection
|
||||||
generalSection
|
generalSection
|
||||||
otherSections
|
otherSections
|
||||||
|
postStreamingSection
|
||||||
AISection
|
AISection
|
||||||
cacheSection
|
cacheSection
|
||||||
}
|
}
|
||||||
|
@ -248,6 +249,23 @@ struct SettingsTabs: View {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private var postStreamingSection: some View {
|
||||||
|
@Bindable var preferences = preferences
|
||||||
|
Section {
|
||||||
|
Toggle(isOn: $preferences.isPostsStreamingEnabled) {
|
||||||
|
Label("Posts streaming", systemImage: "clock.badge")
|
||||||
|
}
|
||||||
|
} header: {
|
||||||
|
Text("Streaming")
|
||||||
|
} footer: {
|
||||||
|
Text("Enabling post streaming will automatically add new posts at the top of your home timeline. Disable if you get performance issues.")
|
||||||
|
}
|
||||||
|
#if !os(visionOS)
|
||||||
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var AISection: some View {
|
private var AISection: some View {
|
||||||
@Bindable var preferences = preferences
|
@Bindable var preferences = preferences
|
||||||
|
|
|
@ -23845,6 +23845,9 @@
|
||||||
},
|
},
|
||||||
"Disable to hide AI assisted tools options such as copywritting and alt image description generated from AI. Use OpenAI API. See our Privacy Policy for more information." : {
|
"Disable to hide AI assisted tools options such as copywritting and alt image description generated from AI. Use OpenAI API. See our Privacy Policy for more information." : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Enabling post streaming will automatically add new posts at the top of your home timeline. Disable if you get performance issues." : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"enum.avatar-position.leading" : {
|
"enum.avatar-position.leading" : {
|
||||||
"comment" : "MARK: Enums",
|
"comment" : "MARK: Enums",
|
||||||
|
@ -42055,6 +42058,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Posts streaming" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Privacy Policy" : {
|
"Privacy Policy" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
@ -77147,6 +77153,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Streaming" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Tab" : {
|
"Tab" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|
|
@ -63,6 +63,8 @@ import SwiftUI
|
||||||
|
|
||||||
@AppStorage("sidebar_expanded") public var isSidebarExpanded: Bool = false
|
@AppStorage("sidebar_expanded") public var isSidebarExpanded: Bool = false
|
||||||
|
|
||||||
|
@AppStorage("stream_new_posts") public var isPostsStreamingEnabled: Bool = false
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
prepareTranslationType()
|
prepareTranslationType()
|
||||||
}
|
}
|
||||||
|
@ -358,6 +360,12 @@ import SwiftUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var isPostsStreamingEnabled: Bool {
|
||||||
|
didSet {
|
||||||
|
storage.isPostsStreamingEnabled = isPostsStreamingEnabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func getRealMaxIndent() -> UInt {
|
public func getRealMaxIndent() -> UInt {
|
||||||
showReplyIndentation ? maxReplyIndentation : 0
|
showReplyIndentation ? maxReplyIndentation : 0
|
||||||
}
|
}
|
||||||
|
@ -533,6 +541,7 @@ import SwiftUI
|
||||||
showAccountPopover = storage.showAccountPopover
|
showAccountPopover = storage.showAccountPopover
|
||||||
muteVideo = storage.muteVideo
|
muteVideo = storage.muteVideo
|
||||||
isSidebarExpanded = storage.isSidebarExpanded
|
isSidebarExpanded = storage.isSidebarExpanded
|
||||||
|
isPostsStreamingEnabled = storage.isPostsStreamingEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -391,9 +391,8 @@ extension TimelineViewModel {
|
||||||
guard let client = client, canStreamEvents, isTimelineVisible else { return }
|
guard let client = client, canStreamEvents, isTimelineVisible else { return }
|
||||||
|
|
||||||
switch event {
|
switch event {
|
||||||
case _ as StreamEventUpdate:
|
case let updateEvent as StreamEventUpdate:
|
||||||
// Removed automatic stream for events.
|
await handleUpdateEvent(updateEvent, client: client)
|
||||||
break
|
|
||||||
case let deleteEvent as StreamEventDelete:
|
case let deleteEvent as StreamEventDelete:
|
||||||
await handleDeleteEvent(deleteEvent)
|
await handleDeleteEvent(deleteEvent)
|
||||||
case let statusUpdateEvent as StreamEventStatusUpdate:
|
case let statusUpdateEvent as StreamEventStatusUpdate:
|
||||||
|
@ -403,6 +402,18 @@ extension TimelineViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func handleUpdateEvent(_ event: StreamEventUpdate, client: Client) async {
|
||||||
|
guard timeline == .home,
|
||||||
|
UserPreferences.shared.isPostsStreamingEnabled,
|
||||||
|
await !datasource.contains(statusId: event.status.id) else { return }
|
||||||
|
|
||||||
|
pendingStatusesObserver.pendingStatuses.insert(event.status.id, at: 0)
|
||||||
|
await datasource.insert(event.status, at: 0)
|
||||||
|
await cache()
|
||||||
|
StatusDataControllerProvider.shared.updateDataControllers(for: [event.status], client: client)
|
||||||
|
await updateStatusesState()
|
||||||
|
}
|
||||||
|
|
||||||
private func handleDeleteEvent(_ event: StreamEventDelete) async {
|
private func handleDeleteEvent(_ event: StreamEventDelete) async {
|
||||||
if let _ = await datasource.remove(event.status) {
|
if let _ = await datasource.remove(event.status) {
|
||||||
await cache()
|
await cache()
|
||||||
|
|
Loading…
Reference in a new issue