adding TheCard preview

This commit is contained in:
or-else
2026-01-17 12:55:45 +03:00
parent 930f4f0656
commit dea781b423
36 changed files with 7720 additions and 201 deletions
+19
View File
@@ -1,4 +1,5 @@
// File and image helper functions.
import { TheCard } from 'tinode-sdk';
// Supported image MIME types and corresponding file extensions.
export const SUPPORTED_IMAGE_FORMATS = ['image/jpeg', 'image/gif', 'image/png', 'image/svg', 'image/svg+xml'];
@@ -305,3 +306,21 @@ export function base64ToIntArray(b64) {
} catch (err) {}
return null;
}
export function importVCard(fileOrBlob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onerror = _ => {
reject(reader.error);
};
reader.onload = _ => {
const card = TheCard.importVCard(reader.result);
if (!card) {
reject(new Error("Failed to parse vCard"));
return;
}
resolve(card);
};
reader.readAsText(fileOrBlob);
});
}