示例#1
0
        public bool IsAvatarReady(TD.User user, Size size)
        {
            var localFilePath = user.ProfilePhoto?.Small?.Local?.Path;

            if (!File.Exists(localFilePath))
            {
                return(false);
            }

            var avatarFile = GetAvatarFilename(size, Path.GetFileNameWithoutExtension(localFilePath));

            return(File.Exists(avatarFile));
        }
示例#2
0
        public bool Retrieve(TD.Chat chat, TD.User user, out Conversation conversation)
        {
            var result = Retrieve(chat.Id, out conversation);

            switch (user.Type)
            {
            case TD.UserType.UserTypeRegular _:
                conversation.Kind = ExplorerEntityKind.People;
                break;

            case TD.UserType.UserTypeBot _:
                conversation.Kind = ExplorerEntityKind.Bot;
                break;
            }

            conversation.Title = chat.Title;
            conversation.Chat  = chat;

            return(result);
        }
示例#3
0
        public async Task <IBitmap> LoadForUserAsync(TD.User user, Size size, bool forceFallback = false)
        {
            string avatarFile;

            if (forceFallback)
            {
                avatarFile = await CreateFallbackAvatar(user.Id, size);
            }
            else
            {
                var localFile = await _fileLoader.LoadFileAsync(user.ProfilePhoto?.Small);

                if (localFile?.Path != null)
                {
                    avatarFile = await CreateAvatar(localFile.Path, size);
                }
                else
                {
                    avatarFile = await CreateFallbackAvatar(user.Id, size);
                }
            }

            return(await CreateBitmap(avatarFile));
        }