Ejemplo n.º 1
0
        private async void ToggleMuteExecute()
        {
            var notifySettings = _full.NotifySettings as TLPeerNotifySettings;

            if (notifySettings != null)
            {
                var muteUntil = notifySettings.MuteUntil == int.MaxValue ? 0 : int.MaxValue;
                var settings  = new TLInputPeerNotifySettings
                {
                    MuteUntil      = muteUntil,
                    IsShowPreviews = notifySettings.IsShowPreviews,
                    IsSilent       = notifySettings.IsSilent,
                    Sound          = notifySettings.Sound
                };

                var response = await ProtoService.UpdateNotifySettingsAsync(new TLInputNotifyPeer { Peer = _item.ToInputPeer() }, settings);

                if (response.IsSucceeded)
                {
                    notifySettings.MuteUntil = muteUntil;
                    RaisePropertyChanged(() => AreNotificationsEnabled);
                    Full.RaisePropertyChanged(() => Full.NotifySettings);

                    var dialog = CacheService.GetDialog(_item.ToPeer());
                    if (dialog != null)
                    {
                        dialog.NotifySettings = _full.NotifySettings;
                        dialog.RaisePropertyChanged(() => dialog.NotifySettings);
                        dialog.RaisePropertyChanged(() => dialog.Self);
                    }

                    CacheService.Commit();
                }
            }
        }
	    public void UpdateNotifySettingsAsync(TLInputNotifyPeerBase peer, TLInputPeerNotifySettings settings, Action<bool> callback, Action<TLRPCError> faultCallback = null)
        {
            //Execute.ShowDebugMessage(string.Format("account.updateNotifySettings peer=[{0}] settings=[{1}]", peer, settings));

            var obj = new TLAccountUpdateNotifySettings { Peer = peer, Settings = settings };

            SendInformativeMessage("account.updateNotifySettings", obj, callback, faultCallback);
        }
        private void UpdateNotifySettingsAsync()
        {
            if (CurrentContact == null)
            {
                return;
            }

            var notifySettings = new TLInputPeerNotifySettings
            {
                EventsMask   = new TLInt(1),
                MuteUntil    = new TLInt(MuteUntil),
                ShowPreviews = new TLBool(true),
                Sound        = string.IsNullOrEmpty(SelectedSound) ? new TLString("default") : new TLString(SelectedSound)
            };

            IsWorking = true;
            MTProtoService.UpdateNotifySettingsAsync(
                CurrentContact.ToInputNotifyPeer(), notifySettings,
                result =>
            {
                IsWorking = false;
                CurrentContact.NotifySettings = new TLPeerNotifySettings
                {
                    EventsMask   = new TLInt(1),
                    MuteUntil    = new TLInt(MuteUntil),
                    ShowPreviews = notifySettings.ShowPreviews,
                    Sound        = notifySettings.Sound
                };

                var dialog = CacheService.GetDialog(new TLPeerUser {
                    Id = CurrentContact.Id
                });
                if (dialog != null)
                {
                    dialog.NotifySettings = CurrentContact.NotifySettings;
                    dialog.NotifyOfPropertyChange(() => dialog.NotifySettings);
                    var settings = dialog.With as INotifySettings;
                    if (settings != null)
                    {
                        settings.NotifySettings = CurrentContact.NotifySettings;
                    }
                }

                CacheService.Commit();
            },
                error =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("account.updateNotifySettings error: " + error);
            });
        }
Ejemplo n.º 4
0
 public virtual void setSettings(TLInputPeerNotifySettings value)
 {
     this.settings = value;
 }
Ejemplo n.º 5
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.peer     = StreamingUtils.readTLObject(stream, context);
     this.settings = StreamingUtils.readTLObject(stream, context);
 }
Ejemplo n.º 6
0
        private void UpdateNotifySettingsAsync()
        {
            if (CurrentItem == null)
            {
                return;
            }

            var notifySettings = new TLInputPeerNotifySettings
            {
                EventsMask   = new TLInt(1),
                MuteUntil    = new TLInt(MuteUntil),
                ShowPreviews = new TLBool(true),
                Sound        = string.IsNullOrEmpty(SelectedSound) ? new TLString("default") : new TLString(SelectedSound)
            };

            IsWorking = true;
            MTProtoService.UpdateNotifySettingsAsync(
                CurrentItem.ToInputNotifyPeer(), notifySettings,
                result =>
            {
                IsWorking = false;
                CurrentItem.NotifySettings = new TLPeerNotifySettings
                {
                    EventsMask   = new TLInt(1),
                    MuteUntil    = new TLInt(MuteUntil),
                    ShowPreviews = notifySettings.ShowPreviews,
                    Sound        = notifySettings.Sound
                };

                var channel = CurrentItem as TLChannel;
                var peer    = channel != null
                        ? (TLPeerBase) new TLPeerChannel {
                    Id = CurrentItem.Id
                }
                        : new TLPeerChat {
                    Id = CurrentItem.Id
                };
                TLDialogBase dialog = CacheService.GetDialog(peer);
                if (dialog == null)
                {
                    if (channel != null)
                    {
                        dialog = DialogsViewModel.GetChannel(channel.Id);
                    }
                }

                if (dialog != null)
                {
                    dialog.NotifySettings = CurrentItem.NotifySettings;
                    dialog.NotifyOfPropertyChange(() => dialog.NotifySettings);
                    var settings = dialog.With as INotifySettings;
                    if (settings != null)
                    {
                        settings.NotifySettings = CurrentItem.NotifySettings;
                    }
                }

                CacheService.Commit();
            },
                error =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("account.updateNotifySettings error: " + error);
            });
        }