4using System.Collections.ObjectModel;
 
    7using CommunityToolkit.Mvvm.ComponentModel;
 
    8using CommunityToolkit.Mvvm.Input;
 
   21        protected override async Task OnInitialize()
 
   23            await base.OnInitialize();
 
   30                MainThread.BeginInvokeOnMainThread(() =>
 
   36                        if (e.Tokens is not null)
 
   38                            foreach (Token Token in e.Tokens)
 
   40                                if (!EventsByCateogy.TryGetValue(Token.TokenId, out NotificationEvent[]? Events))
 
   43                                this.Tokens.Add(new TokenItem(Token, this.navigationArgs?.TokenItemProvider, Events));
 
   46                            this.HasTokens = true;
 
   47                            this.HasMoreTokens = e.Tokens.Length == Constants.BatchSizes.TokenBatchSize;
 
   50                            this.HasTokens = 
false;
 
   53                        this.HasTokens = 
false;
 
   56                ServiceRef.XmppService.NeuroFeatureAdded += this.Wallet_TokenAdded;
 
   57                ServiceRef.XmppService.NeuroFeatureRemoved += this.Wallet_TokenRemoved;
 
   66        protected override Task OnDispose()
 
   68            ServiceRef.XmppService.NeuroFeatureAdded -= this.Wallet_TokenAdded;
 
   69            ServiceRef.XmppService.NeuroFeatureRemoved -= this.Wallet_TokenRemoved;
 
   71            if (this.navigationArgs?.TokenItemProvider is TaskCompletionSource<TokenItem?> TaskSource)
 
   72                TaskSource.TrySetResult(
null);
 
   74            return base.OnDispose();
 
   77        private Task Wallet_TokenAdded(
object? Sender, TokenEventArgs e)
 
   82            MainThread.BeginInvokeOnMainThread(() =>
 
   84                TokenItem Item = 
new(e.Token, this.navigationArgs?.TokenItemProvider, Events);
 
   86                if (this.Tokens.Count == 0)
 
   87                    this.Tokens.Add(Item);
 
   89                    this.Tokens.Insert(0, Item);
 
   92            return Task.CompletedTask;
 
   95        private Task Wallet_TokenRemoved(
object? Sender, TokenEventArgs e)
 
   97            MainThread.BeginInvokeOnMainThread(() =>
 
   99                int i, c = this.Tokens.Count;
 
  101                for (i = 0; i < c; i++)
 
  105                    if (Item.
TokenId == e.Token.TokenId)
 
  107                        this.Tokens.RemoveAt(i);
 
  113            return Task.CompletedTask;
 
  122        private bool hasTokens;
 
  128        private bool hasMoreTokens;
 
  133        public ObservableCollection<TokenItem> Tokens { 
get; } = [];
 
  143            return this.GoBack();
 
  147        public override Task GoBack()
 
  149            this.navigationArgs?.TokenItemProvider.TrySetResult(
null);
 
  150            return base.GoBack();
 
  157        private async Task LoadMoreTokens()
 
  159            if (this.HasMoreTokens)
 
  161                this.HasMoreTokens = 
false; 
 
  168                    MainThread.BeginInvokeOnMainThread(() =>
 
  172                            if (e.Tokens is not null)
 
  174                                foreach (Token Token in e.Tokens)
 
  176                                    if (!EventsByCateogy.TryGetValue(Token.TokenId, out NotificationEvent[]? Events))
 
  179                                    this.Tokens.Add(new TokenItem(Token, Events));
 
  182                                this.HasMoreTokens = e.Tokens.Length == Constants.BatchSizes.TokenBatchSize;
 
const int TokenBatchSize
Number of tokens to load in a single batch.
 
A set of never changing property constants and helpful values.
 
Base class that references services in the app.
 
static ILogService LogService
Log service.
 
static INotificationService NotificationService
Service for managing notifications for the user.
 
static IXmppService XmppService
The XMPP service for XMPP communication.
 
Holds navigation parameters for viewing tokens.
 
Encapsulates a Token object.
 
A view model that holds the XMPP state.
 
bool TryGetNotificationEvents(NotificationEventType Type, CaseInsensitiveString Category, [NotNullWhen(true)] out NotificationEvent[]? Events)
Tries to get available notification events.
 
SortedDictionary< CaseInsensitiveString, NotificationEvent[]> GetEventsByCategory(NotificationEventType Type)
Gets available notification events for a button, sorted by category.
 
abstract class NotificationEvent()
Abstract base class of notification events.
 
NotificationEventType
Button on which event is to be displayed.
 
partial class MyTokensViewModel(MyTokensNavigationArgs? Args)
The view model to bind to for when displaying my tokens.