public void Handle(UploadableItem item) { var userSelf = item.Owner as TLUserSelf; if (userSelf != null) { MTProtoService.UploadProfilePhotoAsync( new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString(Guid.NewGuid() + ".jpg"), Parts = new TLInt(item.Parts.Count) }, new TLString(""), new TLInputGeoPointEmpty(), new TLInputPhotoCropAuto(), photosPhoto => { MTProtoService.GetFullUserAsync(new TLInputUserSelf(), userFull => { }, error => { }); }, error => { }); return; } var chat = item.Owner as TLChat; if (chat != null) { MTProtoService.EditChatPhotoAsync( chat.Id, new TLInputChatUploadedPhoto { File = new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString("chatPhoto.jpg"), Parts = new TLInt(item.Parts.Count) }, Crop = new TLInputPhotoCropAuto() }, photosPhoto => { //MTProtoService.GetFullChatAsync((chat).Id, userFull => //{ // //NotifyOfPropertyChange(() => CurrentItem); //}, //error => { }); }, error => { }); } }
public void Handle(TLUpdatePrivacy privacy) { MTProtoService.GetFullUserAsync((With).ToInputUser(), userFull => { With = userFull.User; NotifyOfPropertyChange(() => With); Subtitle = GetSubtitle(With); NotifyOfPropertyChange(() => Subtitle); }); }
public SettingsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { eventAggregator.Subscribe(this); SuppressUpdateStatus = true; //tombstoning if (stateService.CurrentContact == null) { stateService.ClearNavigationStack = true; navigationService.UriFor <ShellViewModel>().Navigate(); return; } CurrentItem = stateService.CurrentContact; stateService.CurrentContact = null; StateService.GetNotifySettingsAsync( settings => { _locationServices = settings.LocationServices; _peopleHub = settings.PeopleHub; _saveIncomingPhotos = settings.SaveIncomingPhotos; _invisibleMode = settings.InvisibleMode; #if DISABLE_INVISIBLEMODE _invisibleMode = false; #endif BeginOnUIThread(() => { NotifyOfPropertyChange(() => LocationServices); NotifyOfPropertyChange(() => SaveIncomingPhotos); NotifyOfPropertyChange(() => InvisibleMode); }); }); if (CurrentItem == null) { BeginOnThreadPool(() => { MTProtoService.GetFullUserAsync(new TLInputUserSelf(), userFull => { CurrentItem = userFull.User; }); }); } PropertyChanged += OnPropertyChanged; }
public void OpenMediaContact(TLInt userId, TLUserBase user, TLString phoneNumber) { if (user == null) { MTProtoService.GetFullUserAsync(new TLInputUserContact { UserId = userId }, userFull => OpenContactInternal(userFull.User, phoneNumber)); } else { OpenContactInternal(user, phoneNumber); } }
public void Handle(TLUpdateUserBlocked update) { var user = CacheService.GetUser(update.UserId); if (user != null) { UpdateBlockedList(user, update); } else { MTProtoService.GetFullUserAsync( new TLInputUserContact { UserId = update.UserId }, fullUser => UpdateBlockedList(fullUser.User, update)); } }
protected override void OnInitialize() { if (CurrentContact == null) { return; } UpdateNotificationSettings(); UpdateSubtitles(); NotifyOfPropertyChange(() => CurrentContact); if (CurrentContact == null) { return; } Subtitle = DialogDetailsViewModel.GetUserStatus(CurrentContact); Execute.BeginOnThreadPool(TimeSpan.FromSeconds(0.5), () => { UpdateNotificationSettings(); IsWorking = true; MTProtoService.GetFullUserAsync( CurrentContact.ToInputUser(), userFull => { IsWorking = false; UpdateNotificationSettings(); Subtitle = DialogDetailsViewModel.GetUserStatus(CurrentContact); RaiseBlockedStatusChanged(new BlockedEventArgs { Blocked = userFull.Blocked.Value }); }, error => { IsWorking = false; Execute.ShowDebugMessage("users.getFullUser error: " + error); }); }); base.OnInitialize(); }
public void Handle(UploadableItem item) { var userSelf = item.Owner as TLUserSelf; if (userSelf != null) { MTProtoService.UploadProfilePhotoAsync( new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString(Guid.NewGuid() + ".jpg"), Parts = new TLInt(item.Parts.Count) }, new TLString(""), new TLInputGeoPointEmpty(), new TLInputPhotoCropAuto(), photosPhoto => { MTProtoService.GetFullUserAsync(new TLInputUserSelf(), userFull => { }, error => { }); }, error => { }); return; } var channel = item.Owner as TLChannel; if (channel != null) { if (channel.Id != null) { MTProtoService.EditPhotoAsync( channel, new TLInputChatUploadedPhoto { File = new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString("channelPhoto.jpg"), Parts = new TLInt(item.Parts.Count) }, Crop = new TLInputPhotoCropAuto() }, statedMessage => { var updates = statedMessage as TLUpdates; if (updates != null) { var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewChannelMessage) as TLUpdateNewChannelMessage; if (updateNewMessage != null) { EventAggregator.Publish(updateNewMessage.Message); } } }, error => { Execute.ShowDebugMessage("messages.editChatPhoto error " + error); }); } } var chat = item.Owner as TLChat; if (chat != null) { MTProtoService.EditChatPhotoAsync( chat.Id, new TLInputChatUploadedPhoto { File = new TLInputFile { Id = item.FileId, MD5Checksum = new TLString(MD5Core.GetHashString(item.Bytes).ToLowerInvariant()), Name = new TLString("chatPhoto.jpg"), Parts = new TLInt(item.Parts.Count) }, Crop = new TLInputPhotoCropAuto() }, statedMessage => { var updates = statedMessage as TLUpdates; if (updates != null) { var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewMessage) as TLUpdateNewMessage; if (updateNewMessage != null) { EventAggregator.Publish(updateNewMessage.Message); } } }, error => { Execute.ShowDebugMessage("messages.editChatPhoto error " + error); }); } }
public SettingsViewModel(ITransportService transportService, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { eventAggregator.Subscribe(this); TransportService = transportService; SuppressUpdateStatus = true; //tombstoning if (stateService.CurrentContact == null) { ShellViewModel.Navigate(NavigationService); return; } UpdateProxySubtitle(TransportService.GetProxyConfig()); CurrentItem = stateService.CurrentContact; stateService.CurrentContact = null; _allStickers = StateService.GetAllStickers() as TLAllStickers29; _masks = StateService.GetMasks() as TLAllStickers29; _featuredStickers = StateService.GetFeaturedStickers(); if (_featuredStickers != null) { UpdateSets(_featuredStickers, _featuredStickers.Unread); } UpdateStickersSubtitle(_featuredStickers, _allStickers, _masks); StateService.GetNotifySettingsAsync( settings => { _saveIncomingPhotos = settings.SaveIncomingPhotos; _invisibleMode = settings.InvisibleMode; #if DISABLE_INVISIBLEMODE _invisibleMode = false; #endif BeginOnUIThread(() => { NotifyOfPropertyChange(() => SaveIncomingPhotos); NotifyOfPropertyChange(() => InvisibleMode); }); }); if (CurrentItem == null || CurrentItem.NotifySettings == null) { BeginOnThreadPool(() => { MTProtoService.GetFullUserAsync(new TLInputUserSelf(), userFull => { CurrentItem = userFull.User; BeginOnUIThread(() => { var user = CurrentItem as TLUser66; if (user != null) { user.NotifyOfPropertyChange(() => user.About); } }); }); }); } }