Avoid regenerating thumbnail or screenshot on edit
This commit is contained in:
parent
9cf8d06ad1
commit
58c7af6c60
1 changed files with 16 additions and 0 deletions
|
@ -38,6 +38,7 @@ import {
|
||||||
import { missingCaseError } from '../util/missingCaseError.js';
|
import { missingCaseError } from '../util/missingCaseError.js';
|
||||||
import type { MakeVideoScreenshotResultType } from './VisualAttachment.js';
|
import type { MakeVideoScreenshotResultType } from './VisualAttachment.js';
|
||||||
import type { MessageAttachmentType } from './AttachmentDownload.js';
|
import type { MessageAttachmentType } from './AttachmentDownload.js';
|
||||||
|
import { strictAssert } from '../util/assert.js';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isNumber,
|
isNumber,
|
||||||
|
@ -541,6 +542,11 @@ export async function captureDimensionsAndScreenshot(
|
||||||
const localUrl = getLocalAttachmentUrl(attachment);
|
const localUrl = getLocalAttachmentUrl(attachment);
|
||||||
|
|
||||||
if (GoogleChrome.isImageTypeSupported(contentType)) {
|
if (GoogleChrome.isImageTypeSupported(contentType)) {
|
||||||
|
// Already generated thumbnail / width / height
|
||||||
|
if (attachment.thumbnail?.path) {
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { width, height } = await getImageDimensionsFromURL({
|
const { width, height } = await getImageDimensionsFromURL({
|
||||||
objectUrl: localUrl,
|
objectUrl: localUrl,
|
||||||
|
@ -586,6 +592,16 @@ export async function captureDimensionsAndScreenshot(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strictAssert(
|
||||||
|
GoogleChrome.isVideoTypeSupported(contentType),
|
||||||
|
'enforced by early return'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Already generated screenshot / width / height
|
||||||
|
if (attachment.screenshot?.path) {
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
|
||||||
let screenshotObjectUrl: string | undefined;
|
let screenshotObjectUrl: string | undefined;
|
||||||
try {
|
try {
|
||||||
const { blob, duration } = await makeVideoScreenshot({
|
const { blob, duration } = await makeVideoScreenshot({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue