예제 #1
0
        private void OnChatMessageReceivedHandler(object sender, ChatMessageReceivedEventArgs e)
        {
            var chatBook = _store.Find <ChatBook>(e.Sender);

            if (chatBook == null)
            {
                return;
            }

            var chatMessage = new ChatMessage {
                DeliveryState = 3,
                IsIncomming   = true,
                Message       = e.Message
            };

            chatBook.PushMessage(_store, chatMessage);
        }
예제 #2
0
        /// <summary>
        /// Remove friends that aren't found on the given contacts
        /// </summary>
        /// <param name="contacts">Source to look at.</param>
        public async Task RemoveStaleFriendsAsync(List <LocalContact> contacts)
        {
            var stale = Friends
                        .Where(f => contacts.All(c => c.NormalizedPhoneNumber != f.Key))
                        .ToList();

            foreach (var friend in stale)
            {
                await _keyValueStore.Remove(friend);

                Friends.Remove(friend);

                //Remove Chatbook
                var chatbook = _realmStore.Find <ChatBook>(friend.Key);
                if (chatbook != null)
                {
                    await _realmStore.Remove(chatbook);
                }

                OnPropertyChanged(nameof(Friends));
            }
        }