mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Content Scanner Service (#5826)
* implemented the content scanner service with caching and a way to use in the state store context * fix swiftformat comment enforcing * pr suggestions
This commit is contained in:
@@ -30,8 +30,8 @@ class StateStoreViewModel<State: BindableState, ViewAction> {
|
||||
set { context.viewState = newValue }
|
||||
}
|
||||
|
||||
init(initialViewState: State, mediaProvider: MediaProviderProtocol? = nil) {
|
||||
context = Context(initialViewState: initialViewState, mediaProvider: mediaProvider)
|
||||
init(initialViewState: State, mediaProvider: MediaProviderProtocol? = nil, contentScannerService: ContentScannerServiceProtocol? = nil) {
|
||||
context = Context(initialViewState: initialViewState, mediaProvider: mediaProvider, contentScannerService: contentScannerService)
|
||||
context.viewModel = self
|
||||
}
|
||||
|
||||
@@ -66,6 +66,11 @@ class StateStoreViewModel<State: BindableState, ViewAction> {
|
||||
/// Intentionally non-generic so that it doesn't grow uncontrollably
|
||||
let mediaProvider: MediaProviderProtocol?
|
||||
|
||||
/// An optional content scanning service so that views can validate media themselves.
|
||||
/// `nil` when no content scanner is configured for the server, or when the screen
|
||||
/// intentionally doesn't provide one because it has no media to scan.
|
||||
let contentScannerService: ContentScannerServiceProtocol?
|
||||
|
||||
/// Set-able/Bindable access to the bindable state.
|
||||
subscript<T>(dynamicMember keyPath: WritableKeyPath<State.BindStateType, T>) -> T {
|
||||
get { viewState.bindings[keyPath: keyPath] }
|
||||
@@ -78,9 +83,10 @@ class StateStoreViewModel<State: BindableState, ViewAction> {
|
||||
viewModel?.process(viewAction: viewAction)
|
||||
}
|
||||
|
||||
fileprivate init(initialViewState: State, mediaProvider: MediaProviderProtocol?) {
|
||||
fileprivate init(initialViewState: State, mediaProvider: MediaProviderProtocol?, contentScannerService: ContentScannerServiceProtocol?) {
|
||||
self.viewState = initialViewState
|
||||
self.mediaProvider = mediaProvider
|
||||
self.contentScannerService = contentScannerService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user