adding TheCard preview
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import CallMessage from '../widgets/call-message.jsx'
|
||||
import CallStatus from '../widgets/call-status.jsx';
|
||||
import InlineVideo from '../widgets/inline-video.jsx';
|
||||
import LazyImage from '../widgets/lazy-image.jsx';
|
||||
import TheCardViewer from '../widgets/the-card-viewer.jsx';
|
||||
import TheCardMini from '../widgets/the-card-mini.jsx';
|
||||
import UploadingImage from '../widgets/uploading-image.jsx'
|
||||
|
||||
import { BROKEN_IMAGE_SIZE, CLICKABLE_URL_SCHEMES, IMAGE_THUMBNAIL_DIM, NO_DIMENSIONS_VIDEO,
|
||||
@@ -135,7 +135,7 @@ export function fullFormatter(style, data, values, key, stack) {
|
||||
break;
|
||||
case 'TC':
|
||||
// TheCard
|
||||
el = TheCardViewer;
|
||||
el = TheCardMini;
|
||||
attr.content = data;
|
||||
attr.authorizeURL = this.authorizeURL;
|
||||
attr.onChatClick = (e) => this.onHandleClick(e, 'contact_chat');
|
||||
|
||||
Reference in New Issue
Block a user