Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

refactor: extract supportsThumbnails helper function for attachment type checking

DarkPhoenix2704ce092a125e3e
diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts
index e09eb37c80..ff9f9507f2 100644
--- a/packages/nocodb/src/db/BaseModelSqlv2.ts
+++ b/packages/nocodb/src/db/BaseModelSqlv2.ts
@@ -5579,6 +5579,11 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
attachmentColumns: Record<string, any>[],
d: Record<string, any>,
) {
+ // Helper function to check if attachment supports thumbnails
+ const supportsThumbnails = (attachment: any) => {
+ return attachment.mimetype?.startsWith('image/') || attachment.mimetype?.startsWith('application/pdf');
+ };
+
try {
if (d) {
const promises = [];
@@ -5609,7 +5614,7 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
}),
);
- if (!lookedUpAttachment.mimetype?.startsWith('image/') && !lookedUpAttachment.mimetype.startsWith('application/pdf')) {
+ if (!supportsThumbnails(lookedUpAttachment)) {
continue;
}
@@ -5651,7 +5656,7 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
}),
);
- if (!lookedUpAttachment.mimetype?.startsWith('image/') && !lookedUpAttachment.mimetype.startsWith('application/pdf')) {
+ if (!supportsThumbnails(lookedUpAttachment)) {
continue;
}
@@ -5692,7 +5697,7 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
}),
);
- if (!attachment.mimetype?.startsWith('image/') && !attachment.mimetype.startsWith('application/pdf')) {
+ if (!supportsThumbnails(attachment)) {
continue;
}