From 6460f26df1676531a960a9648f42eb1a76ea8042 Mon Sep 17 00:00:00 2001 From: YoanRos Date: Fri, 2 Aug 2024 09:14:39 +0200 Subject: [PATCH] fix: version --- expo/app.versions.json | 2 +- expo/src/scenes/Infos/Transfer.js | 50 ++++++++++++++++++------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/expo/app.versions.json b/expo/app.versions.json index c396a571a..e1ec4a421 100644 --- a/expo/app.versions.json +++ b/expo/app.versions.json @@ -1,4 +1,4 @@ { - "buildNumber": 302, + "buildNumber": 303, "buildName": "1.26.1" } diff --git a/expo/src/scenes/Infos/Transfer.js b/expo/src/scenes/Infos/Transfer.js index 443708ab8..c533a1888 100644 --- a/expo/src/scenes/Infos/Transfer.js +++ b/expo/src/scenes/Infos/Transfer.js @@ -139,28 +139,36 @@ const Transfer = ({ navigation }) => { }; const overwriteData = async (dataImported, pushNotifToken) => { - storage.clearAll(); - storage.set("STORAGE_KEY_PUSH_NOTIFICATION_TOKEN", pushNotifToken); - Object.keys(dataImported).forEach((key) => { - const value = dataImported[key]; - if (typeof value === "object") { - storage.set(key, JSON.stringify(value)); - } else { - storage.set(key, value); - } - }); - const matomoId = storage.getString("@UserIdv2"); - await API.put({ path: `/user`, body: { matomoId, pushNotifToken } }).then((res) => { - if (res.ok) { - Alert.alert("Félicitations, vos données ont bien été importées 🥳"); - logEvent({ category: "TRANSFER", action: "IMPORT_DATA_SUCCESS" }); - Expo.reloadAppAsync(); - } else { - Alert.alert("Félicitations, vos données ont bien été importées 🥳"); - logEvent({ category: "TRANSFER", action: "IMPORT_DATA_SUCCESS", name: "PUSH_NOTIF_TOKEN_NOT_SYNC" }); - Expo.reloadAppAsync(); + try { + if (Object.keys(dataImported).length === 0) { + throw new Error("Imported data is empty"); } - }); + storage.clearAll(); + storage.set("STORAGE_KEY_PUSH_NOTIFICATION_TOKEN", pushNotifToken); + Object.keys(dataImported).forEach((key) => { + const value = dataImported[key]; + if (typeof value === "object") { + storage.set(key, JSON.stringify(value)); + } else { + storage.set(key, value); + } + }); + const matomoId = storage.getString("@UserIdv2"); + await API.put({ path: `/user`, body: { matomoId, pushNotifToken } }).then((res) => { + if (res.ok) { + Alert.alert("Félicitations, vos données ont bien été importées 🥳"); + logEvent({ category: "TRANSFER", action: "IMPORT_DATA_SUCCESS" }); + Expo.reloadAppAsync(); + } else { + Alert.alert("Félicitations, vos données ont bien été importées 🥳"); + logEvent({ category: "TRANSFER", action: "IMPORT_DATA_SUCCESS", name: "PUSH_NOTIF_TOKEN_NOT_SYNC" }); + Expo.reloadAppAsync(); + } + }); + } catch (error) { + Alert.alert("Une erreur est survenue lors de l'importation des données: " + error.message); + logEvent({ category: "TRANSFER", action: "IMPORT_DATA_FAILURE", label: error.message }); + } }; return (