summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2016-01-05 15:49:45 -0500
committerhmhealey <harrisonmhealey@gmail.com>2016-01-06 09:44:12 -0500
commit239d147d9757c62cbfb6ae7b2900b0e5ace6f71c (patch)
tree05032970def7f0a021fe4d5c403f0fb973c24ae9 /web/react/utils
parent0eb145218edb37d911cc5ec135b0006f866a44b2 (diff)
downloadchat-239d147d9757c62cbfb6ae7b2900b0e5ace6f71c.tar.gz
chat-239d147d9757c62cbfb6ae7b2900b0e5ace6f71c.tar.bz2
chat-239d147d9757c62cbfb6ae7b2900b0e5ace6f71c.zip
Changed Audio/Video preview to just display a file info when encountering a file that cannot be played
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/utils.jsx19
1 files changed, 19 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index a808c9be3..41ede7712 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -527,6 +527,25 @@ export function splitFileLocation(fileLocation) {
return {ext: ext, name: filename, path: filePath};
}
+export function getPreviewImagePath(filename) {
+ // Returns the path to a preview image that can be used to represent a file.
+ const fileInfo = splitFileLocation(filename);
+ const fileType = getFileType(fileInfo.ext);
+
+ if (fileType === 'image') {
+ // This is a temporary patch to fix issue with old files using absolute paths
+ if (fileInfo.path.indexOf('/api/v1/files/get') !== -1) {
+ fileInfo.path = fileInfo.path.split('/api/v1/files/get')[1];
+ }
+ fileInfo.path = getWindowLocationOrigin() + '/api/v1/files/get' + fileInfo.path;
+
+ return fileInfo.path + '_preview.jpg?' + getSessionIndex();
+ }
+
+ // only images have proper previews, so just use a placeholder icon for non-images
+ return getPreviewImagePathForFileType(fileType);
+}
+
export function toTitleCase(str) {
function doTitleCase(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();