Exemplo n.º 1
0
        protected override async Task DoReceive()
        {
            if (_listId == null)
            {
                // get description
                var list = (await ReceiveListDescription(_auth, _listInfo));
                await ListProxy.SetListDescription(list);

                _listId = list.Id;
            }
            // if list data is not found, abort receiving timeline.
            if (_listId == null)
            {
                return;
            }
            var id       = _listId.Value;
            var users    = (await ReceiveListMembers(_auth, id)).OrderBy(l => l).ToArray();
            var oldUsers = (await ListProxy.GetListMembers(id)).OrderBy(l => l).ToArray();

            if (users.SequenceEqual(oldUsers))
            {
                // not changed
                return;
            }
            // commit changes
            await ListProxy.SetListMembers(id, users);

            ListMemberChanged.SafeInvoke();
        }
Exemplo n.º 2
0
        private void RefreshMembers()
        {
            Task.Run(async() =>
            {
                if (ListId == 0)
                {
                    var listDesc = await ListProxy.GetListDescription(_info).ConfigureAwait(false);
                    if (listDesc != null)
                    {
                        _listId = listDesc.Id;
                    }
                }
                // list data is not found
                if (ListId == 0)
                {
                    return;
                }

                var userIds = await ListProxy.GetListMembers(ListId).ConfigureAwait(false);
                // user data is not found
                if (userIds == null)
                {
                    return;
                }

                lock (Ids)
                {
                    Ids.Clear();
                    userIds.ForEach(id => Ids.Add(id));
                }
                OnListMemberUpdated.SafeInvoke();
            });
        }