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
@@ -16,7 +16,6 @@ using Disco.Web.Models.Job;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Caching;
@@ -1904,15 +1903,8 @@ namespace Disco.Web.Areas.API.Controllers
var ja = Database.JobAttachments.Find(id);
if (ja != null)
{
var thumbPath = ja.RepositoryThumbnailFilename(Database);
var thumbFileInfo = new FileInfo(thumbPath);
if (thumbFileInfo.Exists && thumbFileInfo.Length > 0)
{
if (thumbPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
return File(thumbPath, "image/png");
else
return File(thumbPath, "image/jpeg");
}
if (ja.WaitForThumbnailGeneration(Database, out var thumbPath, out var mimeType))
return File(thumbPath, mimeType);
else
return File(ClientSource.Style.Images.AttachmentTypes.MimeTypeIcons.Icon(ja.MimeType), "image/png");
}