mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Display the store sizes under the developer options menu
This commit is contained in:
committed by
Stefan Ceriu
parent
8a1d0fe8b1
commit
53a20f2a89
+3
-2
@@ -23,10 +23,11 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(appSettings: AppSettings, appHooks: AppHooks) {
|
||||
init(appSettings: AppSettings, appHooks: AppHooks, clientProxy: ClientProxyProtocol) {
|
||||
viewModel = DeveloperOptionsScreenViewModel(developerOptions: appSettings,
|
||||
elementCallBaseURL: appSettings.elementCallBaseURL,
|
||||
appHooks: appHooks)
|
||||
appHooks: appHooks,
|
||||
clientProxy: clientProxy)
|
||||
|
||||
viewModel.actions
|
||||
.sink { [weak self] action in
|
||||
|
||||
+10
@@ -15,7 +15,17 @@ enum DeveloperOptionsScreenViewModelAction {
|
||||
struct DeveloperOptionsScreenViewState: BindableState {
|
||||
let elementCallBaseURL: URL
|
||||
let appHooks: AppHooks
|
||||
var storeSizes: [StoreSize]?
|
||||
var bindings: DeveloperOptionsScreenViewStateBindings
|
||||
|
||||
struct StoreSize: Identifiable {
|
||||
let name: String
|
||||
let size: String
|
||||
|
||||
var id: String {
|
||||
name + size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// periphery: ignore - subscripts are seen as false positive
|
||||
|
||||
+25
-4
@@ -18,11 +18,32 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL, appHooks: AppHooks) {
|
||||
let bindings = DeveloperOptionsScreenViewStateBindings(developerOptions: developerOptions)
|
||||
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, appHooks: appHooks, bindings: bindings)
|
||||
init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL, appHooks: AppHooks, clientProxy: ClientProxyProtocol) {
|
||||
super.init(initialViewState: .init(elementCallBaseURL: elementCallBaseURL,
|
||||
appHooks: appHooks,
|
||||
bindings: .init(developerOptions: developerOptions)))
|
||||
|
||||
super.init(initialViewState: state)
|
||||
Task {
|
||||
if case let .success(sizes) = await clientProxy.storeSizes() {
|
||||
let formatter = ByteCountFormatStyle(style: .file)
|
||||
|
||||
var components = [DeveloperOptionsScreenViewState.StoreSize]()
|
||||
if let cryptoStore = sizes.cryptoStore {
|
||||
components.append(.init(name: "CryptoStore", size: formatter.format(Int64(cryptoStore))))
|
||||
}
|
||||
if let stateStore = sizes.stateStore {
|
||||
components.append(.init(name: "StateStore", size: formatter.format(Int64(stateStore))))
|
||||
}
|
||||
if let eventCacheStore = sizes.eventCacheStore {
|
||||
components.append(.init(name: "EventCacheStore", size: formatter.format(Int64(eventCacheStore))))
|
||||
}
|
||||
if let mediaStore = sizes.mediaStore {
|
||||
components.append(.init(name: "MediaStore", size: formatter.format(Int64(mediaStore))))
|
||||
}
|
||||
|
||||
state.storeSizes = components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func process(viewAction: DeveloperOptionsScreenViewAction) {
|
||||
|
||||
+10
-1
@@ -21,6 +21,14 @@ struct DeveloperOptionsScreen: View {
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
if let storeSizes = context.viewState.storeSizes {
|
||||
Section("Usage") {
|
||||
ForEach(storeSizes) { storeSize in
|
||||
LabeledContent(storeSize.name, value: storeSize.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section("Logging") {
|
||||
LogLevelConfigurationView(logLevel: $context.logLevel)
|
||||
|
||||
@@ -207,7 +215,8 @@ private extension Set<TraceLogPack> {
|
||||
struct DeveloperOptionsScreen_Previews: PreviewProvider {
|
||||
static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings,
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL,
|
||||
appHooks: AppHooks())
|
||||
appHooks: AppHooks(),
|
||||
clientProxy: ClientProxyMock(.init()))
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
DeveloperOptionsScreen(context: viewModel.context)
|
||||
|
||||
Reference in New Issue
Block a user