Ejemplo n.º 1
0
 /// <summary>
 /// Store the avatar hash for the given jid in the database
 /// </summary>
 /// <param name="from"></param>
 /// <param name="hash"></param>
 private void StoreUserAvatar(Jid from, string hash)
 {
     if (userAvatarStorage.GetUserAvatar(from) == null)
     {
         // no records for Jid => store new record
         userAvatarStorage.AddUserAvatar(from, hash);
     }
     else
     {
         if (userAvatarStorage.GetUserAvatar(from).Hash != hash)
         {
             // records exists, but with a different hash => update
             userAvatarStorage.ReplaceUserAvatar(from, hash);
         }
     }
 }
Ejemplo n.º 2
0
        public async Task RequestRosterAsync()
        {
            var rosterIq = await xmppClient.RequestRosterAsync();

            var rosterItems
                = rosterIq
                  .Query
                  .Cast <Roster>()
                  .GetRoster();

            await Observable.Start(() =>
            {
                foreach (var ri in rosterItems)
                {
                    var contact = mapper.Map <Contact>(ri);

                    if (userAvatarStorage.HasUserAvatar(contact.Jid))
                    {
                        var hash            = userAvatarStorage.GetUserAvatar(contact.Jid).Hash;
                        contact.AvatarBytes = avatarStorage.GetAvatar(hash)?.ImageBytes;
                    }

                    contacts.AddOrReplace(contact, c => c.Jid == contact.Jid);
                }
            }, RxApp.MainThreadScheduler);
        }