diff --git a/lib/Services/downloadConfiguration.dart b/lib/Services/downloadConfiguration.dart index 1d85396..dec881a 100644 --- a/lib/Services/downloadConfiguration.dart +++ b/lib/Services/downloadConfiguration.dart @@ -176,36 +176,30 @@ class _DownloadConfigurationWidgetState extends State 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; } + // 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 sectionIdsToRemove = sectionsInDB.map((s) => s.id).where((sectionId) => !sectionsToKeep.map((sk) => sk.id).contains(sectionId)).toList(); for(var sectionIdToRemove in sectionIdsToRemove) {