public PasswordManagerViewModel(IWindowsManager windowsManager, IQrScannerHelper qrScannerHelper, IMetaPubSub metaMessenger, IActiveDevice activeDevice, ISettingsManager <ApplicationSettings> settingsManager) { this.windowsManager = windowsManager; this.qrScannerHelper = qrScannerHelper; _metaMessenger = metaMessenger; _settingsManager = settingsManager; _metaMessenger.Subscribe <ActiveDeviceChangedMessage>(OnActiveDeviceChanged); _metaMessenger.Subscribe <AddAccountForAppMessage>(OnAddAccountForApp); this.WhenAnyValue(x => x.SearchQuery) .Throttle(TimeSpan.FromMilliseconds(100)) .Where(term => null != term) .DistinctUntilChanged() .InvokeCommand(FilterAccountCommand); this.WhenAnyValue(x => x.Device) .Where(x => null != x) .Subscribe(d => OnDeviceChanged()); this.WhenAnyValue(x => x.SelectedAccount) .InvokeCommand(CancelCommand); // Todo: On update, preserve selection or if unable, clear it //Observable.FromEventPattern<NotifyCollectionChangedEventArgs>(Accounts, nameof(ObservableCollection<string>.CollectionChanged)) // .Subscribe(change => SelectedAccount = Accounts.FirstOrDefault()); Device = activeDevice.Device != null ? new DeviceViewModel(activeDevice.Device) : null; }
public EditAccountViewModel(DeviceViewModel device, AccountRecord accountRecord, IWindowsManager windowsManager, IQrScannerHelper qrScannerHelper, IMetaPubSub metaMessenger) { _windowsManager = windowsManager; _qrScannerHelper = qrScannerHelper; _device = device; _metaMessenger = metaMessenger; if (accountRecord == null) { IsNewAccount = true; cache = new AccountRecord(); AccountRecord = new AccountRecord(); } else { cache = accountRecord; AccountRecord = new AccountRecord { Key = accountRecord.Key, StorageId = accountRecord.StorageId, Timestamp = accountRecord.Timestamp, Flags = accountRecord.Flags, Name = accountRecord.Name, Login = accountRecord.Login, Password = accountRecord.Password, OtpSecret = accountRecord.OtpSecret, Apps = accountRecord.Apps, Urls = accountRecord.Urls, IsPrimary = accountRecord.IsPrimary, }; InitProp(AccountRecord); } HasOpt = cache.Flags.HasOtp; InitDependencies(); }
public EditAccountViewModel(DeviceViewModel device, IWindowsManager windowsManager, IQrScannerHelper qrScannerHelper, IMetaPubSub metaMessenger) : this(device, null, windowsManager, qrScannerHelper, metaMessenger) { }