D1 : enregistrer les ressources de la charge au lieu de les redécouvrir
Le bloc commenté parsait section.data type par type pour retrouver les
ressources à télécharger. Il n'y a plus rien à redécouvrir : le serveur
collecte désormais via GetReferencedResourceIds() et met toutes les
ressources référencées dans la charge d'export.
Répare aussi la purge des fichiers obsolètes : elle est pilotée par
usedImageOrAudioIds, qui ne contenait jusqu'ici que les images de sections —
tout le reste était donc considéré comme inutilisé.
Un nouveau type de section est couvert sans toucher à ce fichier.
flutter analyze sans erreur. ⚠️ Non vérifiable par un build : l'APK ne compile
pas (Gradle/NDK). À confirmer sur device au §21 du plan de test.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
d237987889
commit
dccf211e6f
@ -176,36 +176,30 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Endpoint back with all resources ? Just all get all resourceDTO from a configuration..
|
|
||||||
|
|
||||||
// Download all images..
|
|
||||||
/*ArticleDTO? articleDTO = ArticleDTO.fromJson(jsonDecode(section.data!)); // TODO section data
|
|
||||||
|
|
||||||
if(articleDTO != null) {
|
|
||||||
for(var image in articleDTO.contents!) {
|
|
||||||
usedImageOrAudioIds.add(image.resourceId!);
|
|
||||||
/*var imageData = exportConfigurationDTO.resources!.where((element) => element.id == image.resourceId);
|
|
||||||
if(imageData.isNotEmpty) {
|
|
||||||
// TODO get all resources from API + store it in download directory of the app
|
|
||||||
ResourceModel resourceModel = ResourceModel(id: imageData.first.id, source: image.resourceUrl, /*data: imageData.first.data,*/ type: imageData.first.type);
|
|
||||||
try {
|
|
||||||
await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap());
|
|
||||||
} catch (e) {
|
|
||||||
print("We got an issue inserting image data ${imageData.first.id}");
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
var audioIdsArticle = isAllLanguages ? articleDTO.audioIds! : articleDTO.audioIds!.where((audioId) => audioId.language == visitAppContext.language);
|
|
||||||
for(var audioId in audioIdsArticle) {
|
|
||||||
if(audioId.value != null) {
|
|
||||||
usedImageOrAudioIds.add(audioId.value!);
|
|
||||||
//audiosNotWorking = await importAudio(visitAppContext, exportConfigurationDTO, audioId.value!, audiosNotWorking);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
newOrder = newOrder + 1;
|
newOrder = newOrder + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Le bloc qui vivait ici parsait `section.data` type par type — et il était
|
||||||
|
// commenté, donc une visite téléchargée n'embarquait que l'image de chaque
|
||||||
|
// section : ni contenus d'articles, ni audios, ni icônes de carte.
|
||||||
|
//
|
||||||
|
// Il n'y a plus rien à redécouvrir : depuis le 2026-08-11 le serveur collecte
|
||||||
|
// les ressources via `GetReferencedResourceIds()`, implémentée sur les 13
|
||||||
|
// sous-types, et les met toutes dans `resources`. On enregistre la charge.
|
||||||
|
// Un nouveau type de section est couvert sans toucher à ce fichier.
|
||||||
|
for (var resource in exportConfigurationDTO.resources ?? []) {
|
||||||
|
if (resource.id == null) continue;
|
||||||
|
usedImageOrAudioIds.add(resource.id!);
|
||||||
|
try {
|
||||||
|
await DatabaseHelper.instance.insert(
|
||||||
|
DatabaseTableType.resources,
|
||||||
|
ResourceModel(id: resource.id, source: resource.url, type: resource.type).toMap(),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print("We got an issue inserting resource ${resource.id}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<String?> sectionIdsToRemove = sectionsInDB.map((s) => s.id).where((sectionId) => !sectionsToKeep.map((sk) => sk.id).contains(sectionId)).toList();
|
List<String?> sectionIdsToRemove = sectionsInDB.map((s) => s.id).where((sectionId) => !sectionsToKeep.map((sk) => sk.id).contains(sectionId)).toList();
|
||||||
|
|
||||||
for(var sectionIdToRemove in sectionIdsToRemove) {
|
for(var sectionIdToRemove in sectionIdsToRemove) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user