filter the SelectorProperty source for updates that actually have items; this keeps the currently selected account through server restarts

This commit is contained in:
Jake Norbut committed 2019-07-08 16:29:19 -05:00
1 parent cd744963ff
commit 0e4fe1b47e
1 file changed
+6 -1
@@ -109,9 +109,14 @@ namespace mbts.spark {
() => new InlineUserProperty<AccountTuple>(),
new InlineOrderProperties(),
DictionaryHelper.empty<uint, string>());
// Note that with the .Where on the account_tuples, we will ignore any
// updates for which all accounts have been removed.
// This was a safer change than changing SelectorProperty's IEnumberable.OnNext
// so that it would not reset the selected item on server reboots; i.e. this
// change only affects this IObservable.
_accounts = backing(
nameof(selected_account),
model.factory.subscribe_account_tuples(),
model.factory.subscribe_account_tuples().Where(items => items.Any()),
inline_account_src,
a => new AccountTuple?(a),
() => accounts.Cast<AccountTuple?>().FirstOrDefault(),