Skip to content

Commit

Permalink
Merge pull request #5 from cafebazaar/fix-init-storage
Browse files Browse the repository at this point in the history
fix init storage and syncing
  • Loading branch information
farhadrazzaghi authored Jan 7, 2023
2 parents 1736d95 + 08559f7 commit a3fe842
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 a3fe842

Please sign in to comment.