didvanvoice → fetch list and route to DidvanVoiceList

This commit is contained in:
Mohamad Mahdi Jebeli 2026-06-22 12:24:04 +03:30
parent 8336987f86
commit 6eb00ea786
1 changed files with 35 additions and 1 deletions

View File

@ -326,7 +326,41 @@ class HomeWidgetRepository {
case 'didvanvoice': case 'didvanvoice':
case 'media': case 'media':
route = Routes.didvanVoiceList; // DidvanVoiceList expects List<DidvanVoiceModel>. The notification
// doesn't carry the full list, so we fetch it on the fly the same
// way the legacy int-id branch does.
try {
final service = RequestService(RequestHelper.didvanVoice);
await service.httpGet();
if (service.statusCode == 200) {
final rawData = service.data('result');
List<DidvanVoiceModel> voices = [];
if (rawData is List && rawData.isNotEmpty) {
voices = rawData
.map((e) => DidvanVoiceModel.fromJson(
Map<String, dynamic>.from(e as Map)))
.toList();
} else if (rawData is Map) {
voices = [
DidvanVoiceModel.fromJson(
Map<String, dynamic>.from(rawData)),
];
}
if (voices.isNotEmpty) {
route = Routes.didvanVoiceList;
args = voices;
} else {
route = Routes.home;
}
} else {
route = Routes.home;
}
} catch (e) {
if (kDebugMode) {
print("Error fetching didvan voices for notification: $e");
}
route = Routes.home;
}
break; break;
// Unknown type with a UUID best effort: generic reader. // Unknown type with a UUID best effort: generic reader.