Пример #1
0
        private static void SetMoneyTransfers(AccountBaseInfoSettingsEntry setting, bool isGroupsSetting)
        {
            AppGlobalStateData globalState = AppGlobalStateManager.Current.GlobalState;

            if (!isGroupsSetting)
            {
                globalState.MoneyTransfersEnabled = setting.available;
                globalState.CanSendMoneyTransfers = setting.value == "can_send";
            }
            else
            {
                globalState.CanSendMoneyTransfersToGroups = setting.available;
            }
        }
Пример #2
0
 public void RefreshBaseDataIfNeeded()
 {
     if (this._isLoading || AppGlobalStateManager.Current.LoggedInUserId == 0L)
     {
         return;
     }
     if (this.NeedRefreshBaseData)
     {
         this._isLoading = true;
         AppGlobalStateData globalState = AppGlobalStateManager.Current.GlobalState;
         AccountService.Instance.GetBaseData(AppInfo.GetPhoneAppInfo(), (Action <BackendResult <AccountBaseData, ResultCode> >)(res =>
         {
             if (res.ResultCode == ResultCode.Succeeded)
             {
                 this.UpdateOwnCounters(res.ResultData.OwnCounters);
                 globalState.LoggedInUser = res.ResultData.User;
                 if (res.ResultData.Info != null)
                 {
                     globalState.SupportUri = res.ResultData.Info.support_url;
                     List <AccountBaseInfoSettingsEntry> settings = res.ResultData.Info.settings;
                     if (!settings.IsNullOrEmpty())
                     {
                         AccountBaseInfoSettingsEntry infoSettingsEntry1 = settings.FirstOrDefault <AccountBaseInfoSettingsEntry>((Func <AccountBaseInfoSettingsEntry, bool>)(s => s.name == AccountBaseInfoSettingsEntry.GIF_AUTOPLAY_KEY));
                         if (infoSettingsEntry1 != null)
                         {
                             globalState.GifAutoplayFeatureAvailable = infoSettingsEntry1.available;
                         }
                         AccountBaseInfoSettingsEntry infoSettingsEntry2 = settings.FirstOrDefault <AccountBaseInfoSettingsEntry>((Func <AccountBaseInfoSettingsEntry, bool>)(s => s.name == AccountBaseInfoSettingsEntry.PAYMENT_TYPE_KEY));
                         AccountPaymentType result;
                         if (infoSettingsEntry2 != null && Enum.TryParse <AccountPaymentType>(infoSettingsEntry2.value, out result))
                         {
                             globalState.PaymentType = result;
                         }
                     }
                 }
                 this.UpdateUserInfo();
                 int unixTimestamp = Extensions.DateTimeToUnixTimestamp(DateTime.UtcNow, false);
                 globalState.ServerMinusLocalTimeDelta = res.ResultData.time - unixTimestamp;
                 StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)res.ResultData);
                 EventAggregator.Current.Publish((object)new BaseDataChangedEvent());
                 globalState.GamesSectionEnabled = res.ResultData.GamesSectionEnabled == 1;
                 this.NeedRefreshBaseData        = false;
                 this._lastTimeSetOnline         = DateTime.Now;
             }
             this._isLoading = false;
         }), globalState.NeedRefetchStickers);
     }
     else
     {
         if ((DateTime.Now - this._lastTimeSetOnline).TotalMinutes < 8.0)
         {
             return;
         }
         this._isLoading = true;
         AccountService.Instance.GetIntermediateData((Action <BackendResult <AccountIntermediateData, ResultCode> >)(res =>
         {
             if (res.ResultCode == ResultCode.Succeeded)
             {
                 this._lastTimeSetOnline = DateTime.Now;
                 StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)res.ResultData);
             }
             this._isLoading = false;
         }));
     }
 }
Пример #3
0
        public void RefreshBaseDataIfNeeded()
        {
            if (this._isLoading || AppGlobalStateManager.Current.LoggedInUserId == 0L)
            {
                return;
            }
            if (this.NeedRefreshBaseData)
            {
                this._isLoading = true;
                AppGlobalStateData globalState = AppGlobalStateManager.Current.GlobalState;
                AccountService.Instance.GetBaseData(AppInfo.GetPhoneAppInfo(), (Action <BackendResult <AccountBaseData, ResultCode> >)(res =>
                {
                    if (res.ResultCode == ResultCode.Succeeded)
                    {
                        AccountBaseData resultData = res.ResultData;
                        AccountBaseInfo info       = resultData.Info;
                        BaseDataManager.UpdateOwnCounters(resultData.OwnCounters);
                        globalState.LoggedInUser = resultData.Profile;
                        if (info != null)
                        {
                            globalState.SupportUri = info.support_url;
                            if (info.profiler_settings != null)
                            {
                                foreach (AccountBaseInfoSettingsEntry setting in info.settings)
                                {
                                    switch (setting.name)
                                    {
                                    case "gif_autoplay":
                                        {
                                            BaseDataManager.SetGifAutoplay(setting);
                                            break;
                                        }

                                    case "payment_type":
                                        {
                                            BaseDataManager.SetPaymentType(setting);
                                            break;
                                        }

                                    case "money_p2p":
                                        {
                                            BaseDataManager.SetMoneyTransfers(setting, false);
                                            break;
                                        }

                                    case "money_clubs_p2p":
                                        {
                                            BaseDataManager.SetMoneyTransfers(setting, true);
                                            break;
                                        }
                                    }
                                }
                            }
                            MoneyTransfersSettings moneyP2pParams = info.money_p2p_params;
                            if (moneyP2pParams != null)
                            {
                                globalState.MoneyTransferMinAmount = moneyP2pParams.min_amount;
                                globalState.MoneyTransferMaxAmount = moneyP2pParams.max_amount;
                            }
                        }
                        BaseDataManager.UpdateUserInfo();
                        int unixTimestamp = Extensions.DateTimeToUnixTimestamp(DateTime.UtcNow, false);
                        globalState.ServerMinusLocalTimeDelta = resultData.time - unixTimestamp;
                        StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)resultData);
                        globalState.GamesSectionEnabled = resultData.GamesSectionEnabled == 1;
                        globalState.DebugDisabled       = resultData.DebugDisabled == 1;
                        this.NeedRefreshBaseData        = false;
                        this._lastTimeSetOnline         = DateTime.Now;
                        EventAggregator.Current.Publish(new BaseDataChangedEvent());
                    }
                    this._isLoading = false;
                }), globalState.NeedRefetchStickers);
            }
            else
            {
                if ((DateTime.Now - this._lastTimeSetOnline).TotalMinutes < 8.0)
                {
                    return;
                }
                this._isLoading = true;
                AccountService.Instance.GetIntermediateData((Action <BackendResult <AccountIntermediateData, ResultCode> >)(res =>
                {
                    if (res.ResultCode == ResultCode.Succeeded)
                    {
                        this._lastTimeSetOnline = DateTime.Now;
                        StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)res.ResultData);
                    }
                    this._isLoading = false;
                }));
            }
        }