diff --git a/mobile/lib/utils/file_uploader_util.dart b/mobile/lib/utils/file_uploader_util.dart index e906236322..c9df3b3849 100644 --- a/mobile/lib/utils/file_uploader_util.dart +++ b/mobile/lib/utils/file_uploader_util.dart @@ -336,20 +336,19 @@ Future getPubMetadataRequest( Uint8List fileKey, ) async { final Map jsonToUpdate = - jsonDecode(file.pubMmdEncodedJson ?? '{}'); + file.rAsset?.publicMetadata?.data ?? {}; + newData.forEach((key, value) { jsonToUpdate[key] = value; }); + final int currentVersion = (file.rAsset?.publicMetadata?.version ?? 0); - // update the local information so that it's reflected on UI - file.pubMmdEncodedJson = jsonEncode(jsonToUpdate); - file.pubMagicMetadata = PubMagicMetadata.fromJson(jsonToUpdate); final encryptedMMd = await CryptoUtil.encryptChaCha( utf8.encode(jsonEncode(jsonToUpdate)), fileKey, ); return MetadataRequest( - version: file.pubMmdVersion == 0 ? 1 : file.pubMmdVersion, + version: currentVersion == 0 ? 1 : currentVersion, count: jsonToUpdate.length, data: CryptoUtil.bin2base64(encryptedMMd.encryptedData!), header: CryptoUtil.bin2base64(encryptedMMd.header!),