qol: wait for attachment thumbnail generation and show additional file type-specific icons

This commit is contained in:
Gary Sharp
2024-12-18 19:37:15 +11:00
parent 9f10eeeb70
commit 7550e0e45d
24 changed files with 226 additions and 116 deletions
@@ -6,6 +6,7 @@ using Disco.Services.Plugins.Features.DetailsProvider;
using Disco.Services.Users;
using Disco.Services.Web;
using System;
using System.Data.Entity;
using System.Linq;
using System.Web.Mvc;
@@ -42,14 +43,8 @@ namespace Disco.Web.Areas.API.Controllers
var ua = Database.UserAttachments.Find(id);
if (ua != null)
{
var thumbPath = ua.RepositoryThumbnailFilename(Database);
if (System.IO.File.Exists(thumbPath))
{
if (thumbPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
return File(thumbPath, "image/png");
else
return File(thumbPath, "image/jpeg");
}
if (ua.WaitForThumbnailGeneration(Database, out var thumbPath, out var mimeType))
return File(thumbPath, mimeType);
else
return File(ClientSource.Style.Images.AttachmentTypes.MimeTypeIcons.Icon(ua.MimeType), "image/png");
}