Beispiel #1
0
        async Task Update()
        {
            await ProfileManager.Current.GetProfileData(_friendAccountId, ProfileDownloadType.DownloadIfNotAvailable, true);

            if (_chat == null)
            {
                AddIndex       = GetRow("Misc");
                AddIndexBefore = true;
                AddIndex       = AddHeaderRow("SelectInbox");
                AddIndexBefore = false;

                var result = await _node.DownloadInboxRecords(_friendAccountId);

                if (result.Result == MessageNodeEventResultTypes.Ok)
                {
                    SelectionItem <InboxNameRecordInfo> keyIndexItem = null;
                    var list = new SelectionItemList <InboxNameRecordInfo>();

                    foreach (var item in result.InboxRecords)
                    {
                        var selectionItem = new SelectionItem <InboxNameRecordInfo>(item, null);
                        list.Add(selectionItem);
                        if (item.KeyIndex == _friendKeyIndex)
                        {
                            keyIndexItem = selectionItem;
                        }
                    }

                    if (keyIndexItem != null)
                    {
                        list.Clear();
                        list.Add(keyIndexItem);
                    }

                    var row = AddSelectionRows(list, list[0].Key);
                    row.SelectionChanged = InboxChanged;

                    foreach (var button in row.Buttons)
                    {
                        var item = button.Tag as SelectionItem <InboxNameRecordInfo>;

                        var inboxName = item.Key.InboxRecord?.Title;
                        if (inboxName == null)
                        {
                            inboxName = Tr.Get("Common.Inbox");
                        }

                        button.SetMultilineText(inboxName, Tr.Get("Common.InboxName", _friendAccountId, item.Key.KeyIndex));
                        button.SetDetailViewIcon(Icons.Inbox);
                    }

                    AddIndex = row.Buttons[row.Buttons.Count - 1];
                    AddIndex = AddInfoRow("SelectInboxInfo");
                    var f = AddFooterRow();
                    f.Identifier = "SelectInboxFooter";

                    var friend = _node.GetFriend(_friendAccountId);
                    if (friend != null)
                    {
                        await InboxChanged(list[0].Key);
                    }
                }
                else
                {
                    if (result.Result == MessageNodeEventResultTypes.InvalidAccount)
                    {
                        AddIndex = AddInfoRow("InvalidAccount");
                    }
                    else
                    {
                        AddIndex = AddInfoRow("DownloadFailed");
                    }

                    var f = AddFooterRow();
                    f.Identifier = "SelectInboxFooter";
                }
            }

            IsBusy = false;
        }