public IAsyncOperation <ContentDialogBaseResult> ShowAsync(TLKeyboardButtonSwitchInline switchInline, TLUser bot) { ViewModel.SwitchInline = switchInline; ViewModel.SwitchInlineBot = bot; ViewModel.SendMessage = null; ViewModel.SendMessageUrl = false; return(ShowAsync()); }
public SearchShellViewModel(ICacheService cacheService, IStateService stateService, INavigationService navigationService, SearchDialogsViewModel searchDialogs, SearchMessagesViewModel searchMessages) { _cacheService = cacheService; Recent = new ObservableCollection <TLObject>(); var forwardMessages = stateService.ForwardMessages; var sharedContact = stateService.SharedContact; var logFileName = stateService.LogFileName; var gameString = stateService.GameString; var accessToken = stateService.AccessToken; var bot = stateService.Bot; var webLink = stateService.WebLink; var storageItems = stateService.StorageItems; var url = stateService.Url; var urlText = stateService.UrlText; var loadedDialogs = stateService.LoadedDialogs; var switchInlineButton = stateService.SwitchInlineButton; stateService.ForwardMessages = null; stateService.LogFileName = null; stateService.SharedContact = null; stateService.GameString = null; stateService.AccessToken = null; stateService.Bot = null; stateService.WebLink = null; stateService.StorageItems = null; stateService.Url = null; stateService.UrlText = null; stateService.LoadedDialogs = null; stateService.SwitchInlineButton = null; _forwardMessages = forwardMessages; _sharedContact = sharedContact; _logFileName = logFileName; _gameString = gameString; _accessToken = accessToken; _bot = bot; _webLink = webLink; _storageItems = storageItems; _url = url; _urlText = urlText; _switchInlineButton = switchInlineButton; SearchDialogs = searchDialogs; SearchDialogs.ChatsOnly = bot != null; SearchDialogs.LoadedDilaogs = loadedDialogs; SearchDialogs.OpenDialogDetailsAction = OpenDialogDetails; SearchMessages = searchMessages; SearchMessages.ForwardMessages = forwardMessages; _stateService = stateService; _navigationService = navigationService; if (_stateService.Hashtag != null) { _hashtag = _stateService.Hashtag; _stateService.Hashtag = null; } SearchHint = GetSearchHint(); }
public ChooseDialogViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { FilteredItems = new CollectionViewSource { Source = Items }.View; FilteredItems.Filter += item => { var dialog = item as TLDialog; if (dialog != null) { var chat = dialog.With as TLChat41; if (chat != null) { return(!chat.IsMigrated); } var user = dialog.With as TLUser; if (user != null) { return(!user.IsSelf); } } var dialog71 = dialog as TLDialog71; if (dialog71 != null) { return(!dialog71.IsPromo); } return(true); }; EventAggregator.Subscribe(this); LogFileName = StateService.LogFileName; StateService.LogFileName = null; ForwardedMessages = StateService.ForwardMessages; StateService.ForwardMessages = null; SharedContact = StateService.SharedContact; StateService.SharedContact = null; _gameString = StateService.GameString; StateService.GameString = null; _accessToken = StateService.AccessToken; StateService.AccessToken = null; _bot = StateService.Bot; StateService.Bot = null; _webLink = StateService.WebLink; StateService.WebLink = null; _storageItems = StateService.StorageItems; StateService.StorageItems = null; _url = StateService.Url; StateService.Url = null; _text = StateService.UrlText; StateService.UrlText = null; _switchInlineButton = StateService.SwitchInlineButton; StateService.SwitchInlineButton = null; Status = AppResources.Loading; BeginOnThreadPool(() => { var isAuthorized = SettingsHelper.GetValue <bool>(Constants.IsAuthorizedKey); if (isAuthorized) { var dialogs = CacheService.GetDialogs(); var dialogsCache = new Dictionary <int, TLDialogBase>(); var clearedDialogs = new List <TLDialogBase>(); foreach (var dialog in dialogs) { if (!dialogsCache.ContainsKey(dialog.Index)) { var user = dialog.With as TLUser; if (user != null && user.IsSelf) { CurrentUser = dialog; } if (dialog is TLDialog || dialog is TLBroadcastDialog) { if (!SkipDialogForBot(_bot, dialog)) { clearedDialogs.Add(dialog); } dialogsCache[dialog.Index] = dialog; } } else { var cachedDialog = dialogsCache[dialog.Index]; if (cachedDialog.Peer is TLPeerUser && dialog.Peer is TLPeerUser) { CacheService.DeleteDialog(dialog); continue; } if (cachedDialog.Peer is TLPeerChat && dialog.Peer is TLPeerChat) { CacheService.DeleteDialog(dialog); continue; } } } if (CurrentUser == null) { var currentUser = CacheService.GetUser(new TLInt(StateService.CurrentUserId)); if (currentUser != null) { var dialog = new TLDialog71 { With = currentUser, Flags = new TLInt(0), Peer = new TLPeerUser { Id = currentUser.Id }, Messages = new ObservableCollection <TLMessageBase>(), TopMessageId = new TLInt(0), ReadInboxMaxId = new TLInt(0), ReadOutboxMaxId = new TLInt(0), UnreadCount = new TLInt(0), UnreadMentionsCount = new TLInt(0), NotifySettings = new TLPeerNotifySettings78 { Flags = new TLInt(0), MuteUntil = new TLInt(0), Sound = new TLString("Default") } }; CurrentUser = dialog; } } BeginOnUIThread(() => { NotifyOfPropertyChange(() => CurrentUser); foreach (var clearedDialog in clearedDialogs) { LazyItems.Add(clearedDialog); } var lastDialog = clearedDialogs.LastOrDefault(x => x.TopMessageId != null); _maxId = lastDialog != null ? lastDialog.TopMessageId.Value : 0; Status = LazyItems.Count == 0 ? AppResources.Loading : string.Empty; var importantCount = 0; var count = 0; for (var i = 0; i < LazyItems.Count && importantCount < FirstSliceLength; i++, count++) { Items.Add(LazyItems[i]); var chat41 = LazyItems[i].With as TLChat41; if (chat41 == null || chat41.MigratedTo == null) { importantCount++; } } BeginOnUIThread(TimeSpan.FromSeconds(0.5), () => { for (var i = count; i < LazyItems.Count; i++) { Items.Add(LazyItems[i]); } LazyItems.Clear(); LoadNextSlice(); }); }); } }); }