Remove the CommonSettingsProtocol and use UserSession to carry multiple dependencies. (#6302)

* Remove the CommonSettingsProtocol.

* Replace multiple dependencies with the UserSession when it carries them.
This commit is contained in:
Doug
2026-10-09 10:20:00 +01:00
committed by GitHub
parent a3d170534c
commit 65bab49f39
75 changed files with 212 additions and 369 deletions
@@ -15,11 +15,11 @@ enum RemoteSettingsError: Error {
protocol RemoteSettingsHookProtocol: Sendable {
#if IS_MAIN_APP
@MainActor func initializeCache(using client: ClientProtocol, applyingTo appSettings: CommonSettingsProtocol) async -> Result<Void, RemoteSettingsError>
@MainActor func initializeCache(using client: ClientProtocol, applyingTo appSettings: AppSettings) async -> Result<Void, RemoteSettingsError>
func updateCache(using client: ClientProtocol) async
@MainActor func reset(_ appSettings: CommonSettingsProtocol)
@MainActor func reset(_ appSettings: AppSettings)
#endif
@MainActor func loadCache(forHomeserver homeserver: String, applyingTo appSettings: CommonSettingsProtocol)
@MainActor func loadCache(forHomeserver homeserver: String, applyingTo appSettings: AppSettings)
}
struct DefaultRemoteSettingsHook: RemoteSettingsHookProtocol {
@@ -27,7 +27,7 @@ struct DefaultRemoteSettingsHook: RemoteSettingsHookProtocol {
/// A best effort implementation to let Element X advertise to users when they should be using
/// Element Pro. In an ideal world the backend would be able to validate the client's requests
/// instead of relying on it to check a well-known file for this.
func initializeCache(using client: ClientProtocol, applyingTo appSettings: CommonSettingsProtocol) async -> Result<Void, RemoteSettingsError> {
func initializeCache(using client: ClientProtocol, applyingTo appSettings: AppSettings) async -> Result<Void, RemoteSettingsError> {
guard case let .success(wellKnownData) = await client.elementWellKnown() else {
// Nothing to check, carry on as normal.
return .success(())
@@ -49,10 +49,10 @@ struct DefaultRemoteSettingsHook: RemoteSettingsHookProtocol {
}
func updateCache(using client: ClientProtocol) async { }
func reset(_ appSettings: any CommonSettingsProtocol) { }
func reset(_ appSettings: AppSettings) { }
#endif
func loadCache(forHomeserver homeserver: String, applyingTo appSettings: CommonSettingsProtocol) { }
func loadCache(forHomeserver homeserver: String, applyingTo appSettings: AppSettings) { }
}
private struct ElementWellKnown: Decodable {