From 08559f78c47c1e7841917038d925178ad30b2f55 Mon Sep 17 00:00:00 2001 From: Farhadrzi Date: Sun, 1 Jan 2023 15:40:17 +0300 Subject: [PATCH] fix init storage and syncing --- .../Script/AuthAndStorage/AuthAndStorageBridge.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Assets/Cafebazaar/Core/Script/AuthAndStorage/AuthAndStorageBridge.cs b/Assets/Cafebazaar/Core/Script/AuthAndStorage/AuthAndStorageBridge.cs index 8ca5c38..3e34d4f 100644 --- a/Assets/Cafebazaar/Core/Script/AuthAndStorage/AuthAndStorageBridge.cs +++ b/Assets/Cafebazaar/Core/Script/AuthAndStorage/AuthAndStorageBridge.cs @@ -145,6 +145,7 @@ public void OnLoginFailed() } #endregion #region STORAGE System + private readonly Dictionary storageKeyValue = new Dictionary(); public bool StorageIsInit { get; private set; } public bool Storage_Is_Synced { get; private set; } public bool Storage_Is_Syncing { get; private set; } @@ -190,6 +191,8 @@ public void STORAGE_Init(Action OnResult) if (Application.platform == RuntimePlatform.Android) { #if UNITY_ANDROID + SavedInitData(OnResult); + CallbackHolder.Instance.RegisterCallBack("OnGetDataSucceed", (x) => { OnResult((InitStorageResult)x); }); CallbackHolder.Instance.RegisterCallBack("OnGetDataFailed", (x) => { OnResult((InitStorageResult)x); }); @@ -265,6 +268,15 @@ public void OnSaveDataFailed(string error) CallbackHolder.Instance.ExecuteCallBack("OnSaveDataFailed", setStorageResult); } + private void SavedInitData(Action OnResult) + { + CallbackHolder.Instance.RegisterCallBack("OnSaveDataSucceed", (x) => { OnResult((InitStorageResult)x); }); + CallbackHolder.Instance.RegisterCallBack("OnSaveDataFailed", (x) => { OnResult((InitStorageResult)x); }); + storageKeyValue.Add("initCafeBazaar", "true"); + string data = Storage_CalculateSaveData(); + bazaarBridgePlugin.Call("SaveData", data); + } + private IEnumerator IEOnLoginToCafebazaarSuccessfull(Action OnResult, SignInResult loginResult) { yield return true; @@ -275,7 +287,6 @@ private IEnumerator IEOnLoginToCafebazaarSuccessfull(Action OnResu OnResult(loginResult); } - private readonly Dictionary storageKeyValue = new Dictionary(); private static bool init_storageLoop; private static float lastChangeStorage;