didvanvoice → fetch list and route to DidvanVoiceList
This commit is contained in:
parent
8336987f86
commit
6eb00ea786
|
|
@ -326,7 +326,41 @@ class HomeWidgetRepository {
|
||||||
|
|
||||||
case 'didvanvoice':
|
case 'didvanvoice':
|
||||||
case 'media':
|
case 'media':
|
||||||
|
// 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;
|
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.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue