feat(home): expose extension country settings and isolate regional caches

This commit is contained in:
zarzet committed 2026-10-18 03:11:33 +07:00
1 parent 2455cabced
commit 1a6dc7366e
11 files changed
+606 -21

No files matched your search

+20
View File
@@ -244,6 +244,22 @@ class Extension {
bool get hasPostProcessing => postProcessing?.enabled ?? false;
bool get hasServiceHealth => serviceHealth.isNotEmpty;
bool get hasHomeFeed => capabilities['homeFeed'] == true;
/// The extension owns its country choices and the setting sent to its API.
ExtensionSetting? get homeFeedRegionSetting {
if (!hasHomeFeed) return null;
final key = capabilities['homeFeedRegionSetting'];
if (key is! String || key.isEmpty) return null;
return settings.where((setting) {
final options = setting.options;
return setting.key == key &&
(setting.type == 'select' || setting.type == 'string') &&
options != null &&
options.isNotEmpty &&
options.every((code) => RegExp(r'^[a-zA-Z]{2}$').hasMatch(code));
}).firstOrNull;
}
ExtensionDownloadTransferPolicy get downloadTransferPolicy =>
ExtensionDownloadTransferPolicy.fromCapabilities(capabilities);
bool get requiresNativeContainerConversion =>
@@ -760,6 +776,7 @@ class ExtensionState {
final bool isLoading;
final String? error;
final bool isInitialized;
final Map<String, int> settingsRevisions;
const ExtensionState({
this.extensions = const [],
@@ -769,6 +786,7 @@ class ExtensionState {
this.isLoading = false,
this.error,
this.isInitialized = false,
this.settingsRevisions = const {},
});
ExtensionState copyWith({
@@ -779,6 +797,7 @@ class ExtensionState {
bool? isLoading,
String? error,
bool? isInitialized,
Map<String, int>? settingsRevisions,
}) {
return ExtensionState(
extensions: extensions ?? this.extensions,
@@ -789,6 +808,7 @@ class ExtensionState {
isLoading: isLoading ?? this.isLoading,
error: error,
isInitialized: isInitialized ?? this.isInitialized,
settingsRevisions: settingsRevisions ?? this.settingsRevisions,
);
}
}