[MM-47801][MM-45980] Added support for security-scoped bookmarks to allow the MAS build to save files wherever needed (#2315)
* First pass * [MM-47801] Added support for security-scoped bookmarks to allow the MAS build to save files wherever needed
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {DownloadedItem} from 'types/downloads';
|
||||
|
||||
import {CheckCircleIcon, CloseCircleIcon} from '@mattermost/compass-icons/components';
|
||||
@@ -19,6 +19,8 @@ const colorRed = '#D24B4E';
|
||||
const isWin = window.process.platform === 'win32';
|
||||
|
||||
const Thumbnail = ({item}: OwnProps) => {
|
||||
const [imageUrl, setImageUrl] = useState<string | undefined>();
|
||||
|
||||
const showBadge = (state: DownloadedItem['state']) => {
|
||||
switch (state) {
|
||||
case 'completed':
|
||||
@@ -42,15 +44,27 @@ const Thumbnail = ({item}: OwnProps) => {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const fetchThumbnail = async () => {
|
||||
const imageUrl = await window.mas.getThumbnailLocation(item.location);
|
||||
setImageUrl(imageUrl);
|
||||
};
|
||||
|
||||
fetchThumbnail();
|
||||
}, [item]);
|
||||
|
||||
const showImagePreview = isImageFile(item) && item.state === 'completed';
|
||||
if (showImagePreview && !imageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='DownloadsDropdown__Thumbnail__Container'>
|
||||
{showImagePreview ?
|
||||
{showImagePreview && imageUrl ?
|
||||
<div
|
||||
className='DownloadsDropdown__Thumbnail preview'
|
||||
style={{
|
||||
backgroundImage: `url("${isWin ? `file:///${item.location.replaceAll('\\', '/')}` : item.location}")`,
|
||||
backgroundImage: `url("${isWin ? `file:///${imageUrl.replaceAll('\\', '/')}` : imageUrl}")`,
|
||||
backgroundSize: 'cover',
|
||||
}}
|
||||
/> :
|
||||
|
Reference in New Issue
Block a user