public ChatPhotosViewModel(IMTProtoService protoService, TLChatFullBase chatFull, TLChatBase chat) : base(protoService, null, null) { _peer = chat.ToInputPeer(); _lastMaxId = int.MaxValue; Items = new MvxObservableCollection <GalleryItem> { new GalleryPhotoItem(chatFull.ChatPhoto as TLPhoto, chat) }; SelectedItem = Items[0]; FirstItem = Items[0]; Initialize(); }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { Task <MTProtoResponse <TLExportedChatInviteBase> > task = null; if (parameter is TLPeerChannel peerChannel) { _peer = peerChannel; var channel = CacheService.GetChat(peerChannel.ChannelId) as TLChannel; if (channel != null) { Item = channel; var full = CacheService.GetFullChat(channel.Id) as TLChannelFull; if (full == null) { var response = await ProtoService.GetFullChannelAsync(channel.ToInputChannel()); if (response.IsSucceeded) { full = response.Result.FullChat as TLChannelFull; } } if (full != null) { _full = full; _exportedInvite = full.ExportedInvite; if (full.ExportedInvite is TLChatInviteExported invite) { InviteLink = invite.Link; } else { task = ProtoService.ExportInviteAsync(channel.ToInputChannel()); } } } } else if (parameter is TLPeerChat peerChat) { _peer = peerChat; var chat = CacheService.GetChat(peerChat.ChatId) as TLChat; if (chat != null) { Item = chat; var full = CacheService.GetFullChat(chat.Id) as TLChatFull; if (full == null) { var response = await ProtoService.GetFullChatAsync(chat.Id); if (response.IsSucceeded) { full = response.Result.FullChat as TLChatFull; } } if (full != null) { _exportedInvite = full.ExportedInvite; if (full.ExportedInvite is TLChatInviteExported invite) { InviteLink = invite.Link; } else { task = ProtoService.ExportChatInviteAsync(chat.Id); } } } } if (task != null) { var response = await task; if (response.IsSucceeded) { _exportedInvite = response.Result; if (_full != null) { _full.ExportedInvite = response.Result; } var invite = response.Result as TLChatInviteExported; if (invite != null && !string.IsNullOrEmpty(invite.Link)) { InviteLink = invite.Link; } } else { Execute.ShowDebugMessage("channels.exportInvite error " + response.Error); } } }
public ChatPhotosViewModel(IMTProtoService protoService, ICacheService cacheService, TLChatFullBase chatFull, TLChatBase chat, TLMessageService serviceMessage) : base(protoService, cacheService, null) { _peer = chat.ToInputPeer(); _lastMaxId = serviceMessage.Id; if (serviceMessage.Action is TLMessageActionChatEditPhoto editPhotoAction) { Items = new MvxObservableCollection <GalleryItem> { new GalleryPhotoItem(editPhotoAction.Photo as TLPhoto, chat) }; SelectedItem = Items[0]; FirstItem = Items[0]; } Initialize(serviceMessage.Id); }