Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import SwiftUI
private struct GlobalEnvModifier: ViewModifier {

@State private var windowHolder = WindowHolder(window: nil)
@Injected(\.userDefaultsStorage)
private var userDefaults: any UserDefaultsStorageProtocol
@Injected(\.legacyViewControllerProvider)
private var viewControllerProvider: any ViewControllerProviderProtocol
@State private var model = GlobalEnvModifierModel()

func body(content: Content) -> some View {
content
Expand All @@ -17,13 +14,30 @@ private struct GlobalEnvModifier: ViewModifier {
.setAppInterfaceStyleEnv(window: windowHolder.window)
// Legacy :(
.onChange(of: windowHolder) { _, newValue in
viewControllerProvider.setSceneWindow(newValue.window)
newValue.window?.overrideUserInterfaceStyle = userDefaults.userInterfaceStyle
model.setSceneWindow(newValue.window)
newValue.window?.overrideUserInterfaceStyle = model.userInterfaceStyle
}

}
}

@MainActor
@Observable
private final class GlobalEnvModifierModel {
@Injected(\.userDefaultsStorage) @ObservationIgnored
private var userDefaults: any UserDefaultsStorageProtocol
@Injected(\.legacyViewControllerProvider) @ObservationIgnored
private var viewControllerProvider: any ViewControllerProviderProtocol

var userInterfaceStyle: UIUserInterfaceStyle {
userDefaults.userInterfaceStyle
}

func setSceneWindow(_ window: UIWindow?) {
viewControllerProvider.setSceneWindow(window)
}
}

extension View {
func setupGlobalEnv() -> some View {
self.modifier(GlobalEnvModifier())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import Services
struct TodoIconView: View {

private static let maxSide = 28.0

@Injected(\.objectActionsService)
private var objectActionsService: any ObjectActionsServiceProtocol
@State private var model = TodoIconViewModel()

let checked: Bool
let objectId: String?
Expand All @@ -20,10 +18,22 @@ struct TodoIconView: View {
.frame(maxWidth: 28, maxHeight: 28)
.onTapGesture {
guard let objectId else { return }
Task {
try await objectActionsService.updateBundledDetails(contextID: objectId, details: [.done(!checked)])
UIImpactFeedbackGenerator(style: .rigid).impactOccurred()
}
model.updateDone(objectId: objectId, checked: !checked)
}
}
}

@MainActor
@Observable
private final class TodoIconViewModel {

@Injected(\.objectActionsService) @ObservationIgnored
private var objectActionsService: any ObjectActionsServiceProtocol

func updateDone(objectId: String, checked: Bool) {
Task {
try await objectActionsService.updateBundledDetails(contextID: objectId, details: [.done(checked)])
UIImpactFeedbackGenerator(style: .rigid).impactOccurred()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import SwiftUI
import Services


struct ExportStackGoroutinesViewModifier: ViewModifier {
@Injected(\.debugService)
private var debugService: any DebugServiceProtocol

@State private var model = ExportStackGoroutinesViewModel()
@State private var shareUrlFile: URL?
@Binding var isPresented: Bool

Expand All @@ -21,10 +19,21 @@ struct ExportStackGoroutinesViewModifier: ViewModifier {
}

private func exportStackGoroutines() {
Task { shareUrlFile = try await debugService.exportStackGoroutinesZip() }
Task { shareUrlFile = try await model.exportStackGoroutinesZip() }
}
}

@MainActor
@Observable
private final class ExportStackGoroutinesViewModel {

@Injected(\.debugService) @ObservationIgnored
private var debugService: any DebugServiceProtocol

func exportStackGoroutinesZip() async throws -> URL {
try await debugService.exportStackGoroutinesZip()
}
}

extension View {
func exportStackGoroutinesSheet(isPresented: Binding<Bool>) -> some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import Factory
import AnytypeCore

@MainActor
protocol AttachmentProcessor {
protocol AttachmentProcessor: AnyObject {
associatedtype Input
func process(_ input: Input, spaceId: String) throws -> ChatLinkedObject
}

@MainActor
protocol AsyncAttachmentProcessor {
protocol AsyncAttachmentProcessor: AnyObject {
associatedtype Input
func process(_ input: Input, spaceId: String) async throws -> ChatLinkedObject
}

@MainActor
struct FileAttachmentProcessor: AttachmentProcessor {
final class FileAttachmentProcessor: AttachmentProcessor {

@Injected(\.fileActionsService)
private var fileActionsService: any FileActionsServiceProtocol
Expand All @@ -39,7 +39,7 @@ struct FileAttachmentProcessor: AttachmentProcessor {
}

@MainActor
struct CameraMediaProcessor: AttachmentProcessor {
final class CameraMediaProcessor: AttachmentProcessor {

@Injected(\.fileActionsService)
private var fileActionsService: any FileActionsServiceProtocol
Expand All @@ -61,7 +61,7 @@ struct CameraMediaProcessor: AttachmentProcessor {
}

@MainActor
struct PhotosPickerProcessor: AsyncAttachmentProcessor {
final class PhotosPickerProcessor: AsyncAttachmentProcessor {

@Injected(\.fileActionsService)
private var fileActionsService: any FileActionsServiceProtocol
Expand All @@ -73,7 +73,7 @@ struct PhotosPickerProcessor: AsyncAttachmentProcessor {
}

@MainActor
struct PasteBufferProcessor: AsyncAttachmentProcessor {
final class PasteBufferProcessor: AsyncAttachmentProcessor {

@Injected(\.fileActionsService)
private var fileActionsService: any FileActionsServiceProtocol
Expand All @@ -87,7 +87,7 @@ struct PasteBufferProcessor: AsyncAttachmentProcessor {
}

@MainActor
struct LinkPreviewProcessor: AsyncAttachmentProcessor {
final class LinkPreviewProcessor: AsyncAttachmentProcessor {

@Injected(\.bookmarkService)
private var bookmarkService: any BookmarkServiceProtocol
Expand All @@ -106,7 +106,7 @@ struct LinkPreviewProcessor: AsyncAttachmentProcessor {
}

@MainActor
struct UploadedObjectProcessor: AttachmentProcessor {
final class UploadedObjectProcessor: AttachmentProcessor {

func process(_ input: MessageAttachmentDetails, spaceId: String) throws -> ChatLinkedObject {
return .uploadedObject(input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct AttachmentValidationResult {
}

@MainActor
struct ChatAttachmentValidator {
final class ChatAttachmentValidator {

@Injected(\.chatMessageLimits)
private var chatMessageLimits: any ChatMessageLimitsProtocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Combine
import AnytypeCore

@MainActor
struct BlockImageViewModel: BlockViewModelProtocol {
final class BlockImageViewModel: BlockViewModelProtocol {
typealias Action<T> = (_ arg: T) -> Void

@Injected(\.openedDocumentProvider)
Expand Down