Skip to content

Commit

Permalink
fix init storage and syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhadrzi committed Jan 1, 2023
1 parent 1736d95 commit 08559f7
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public void OnLoginFailed()
}
#endregion
#region STORAGE System
private readonly Dictionary<string, string> storageKeyValue = new Dictionary<string, string>();
public bool StorageIsInit { get; private set; }
public bool Storage_Is_Synced { get; private set; }
public bool Storage_Is_Syncing { get; private set; }
Expand Down Expand Up @@ -190,6 +191,8 @@ public void STORAGE_Init(Action<InitStorageResult> 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); });

Expand Down Expand Up @@ -265,6 +268,15 @@ public void OnSaveDataFailed(string error)
CallbackHolder.Instance.ExecuteCallBack("OnSaveDataFailed", setStorageResult);
}

private void SavedInitData(Action<InitStorageResult> 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<SignInResult> OnResult, SignInResult loginResult)
{
yield return true;
Expand All @@ -275,7 +287,6 @@ private IEnumerator IEOnLoginToCafebazaarSuccessfull(Action<SignInResult> OnResu
OnResult(loginResult);
}

private readonly Dictionary<string, string> storageKeyValue = new Dictionary<string, string>();
private static bool init_storageLoop;
private static float lastChangeStorage;

Expand Down

0 comments on commit 08559f7

Please sign in to comment.