diff --git a/app/client/mobile/src/download.ts b/app/client/mobile/src/download.ts index 12c3910d..ac245b97 100644 --- a/app/client/mobile/src/download.ts +++ b/app/client/mobile/src/download.ts @@ -11,8 +11,6 @@ export async function Download(uri: string, name: string, extension?: string) { const type = extension ? extension : (await fileType(downloadPath))?.ext; -console.log(type, extension); - const dir = Platform.OS === 'ios' ? RNFS.DocumentDirectoryPath : RNFS.DownloadDirectoryPath; const sharePath = `${dir}/${name}.${type}`; if (await RNFS.exists(sharePath)) { @@ -20,6 +18,12 @@ console.log(type, extension); } await RNFS.moveFile(downloadPath, sharePath); - await Share.share({ url: sharePath }); + + if (Platform.OS === 'ios') { + await Share.share({ url: sharePath }); + } else { + await RNFS.scanFile(sharePath); + } + await RNFS.unlink(sharePath); } diff --git a/app/client/mobile/src/message/audioAsset/AudioAsset.styled.ts b/app/client/mobile/src/message/audioAsset/AudioAsset.styled.ts index e777bc70..96a3eea1 100644 --- a/app/client/mobile/src/message/audioAsset/AudioAsset.styled.ts +++ b/app/client/mobile/src/message/audioAsset/AudioAsset.styled.ts @@ -80,7 +80,6 @@ export const styles = StyleSheet.create({ }, closeIcon: { flexShrink: 0, - backgroundColor: 'transparent', }, progress: { position: 'absolute', diff --git a/app/client/mobile/src/message/audioAsset/AudioAsset.tsx b/app/client/mobile/src/message/audioAsset/AudioAsset.tsx index efee81b6..c856710b 100644 --- a/app/client/mobile/src/message/audioAsset/AudioAsset.tsx +++ b/app/client/mobile/src/message/audioAsset/AudioAsset.tsx @@ -15,6 +15,7 @@ export function AudioAsset({ topicId, asset, loaded, show }: { topicId: string, const opacity = useAnimatedValue(0); const videoRef = useRef(null as null | VideoRef); const [status, setStatus] = useState('loading'); + const [downloading, setDownloading] = useState(false); useEffect(() => { if (show) { @@ -56,6 +57,18 @@ export function AudioAsset({ topicId, asset, loaded, show }: { topicId: string, } } + const download = async () => { + if (!downloading) { + setDownloading(true); + try { + await actions.download(); + } catch (err) { + console.log(err); + } + setDownloading(false); + } + } + return ( @@ -100,7 +113,7 @@ export function AudioAsset({ topicId, asset, loaded, show }: { topicId: string, )} { state.dataUrl && ( - + )} { asset.audio?.label || asset.encrypted?.label } diff --git a/app/client/mobile/src/message/binaryAsset/BinaryAsset.styled.ts b/app/client/mobile/src/message/binaryAsset/BinaryAsset.styled.ts index de5b5619..583d9468 100644 --- a/app/client/mobile/src/message/binaryAsset/BinaryAsset.styled.ts +++ b/app/client/mobile/src/message/binaryAsset/BinaryAsset.styled.ts @@ -85,7 +85,6 @@ export const styles = StyleSheet.create({ color: Colors.offsync, }, closeIcon: { - backgroundColor: 'transparent', }, progress: { position: 'absolute', diff --git a/app/client/mobile/src/message/binaryAsset/BinaryAsset.tsx b/app/client/mobile/src/message/binaryAsset/BinaryAsset.tsx index d70195a6..97f9b5be 100644 --- a/app/client/mobile/src/message/binaryAsset/BinaryAsset.tsx +++ b/app/client/mobile/src/message/binaryAsset/BinaryAsset.tsx @@ -13,6 +13,7 @@ export function BinaryAsset({ topicId, asset, loaded, show }: { topicId: string, const [modal, setModal] = useState(false); const opacity = useAnimatedValue(0); const [alert, setAlert] = useState(''); + const [downloading, setDownloading] = useState(false); useEffect(() => { if (show) { @@ -45,8 +46,20 @@ export function BinaryAsset({ topicId, asset, loaded, show }: { topicId: string, actions.cancelLoad(); } + const download = async () => { + if (!downloading) { + setDownloading(true); + try { + await actions.download(); + } catch (err) { + console.log(err); + } + setDownloading(false); + } + } + return ( - + { state.dataUrl && ( - + )} diff --git a/app/client/mobile/src/message/imageAsset/ImageAsset.tsx b/app/client/mobile/src/message/imageAsset/ImageAsset.tsx index 44ef7210..52bd2df6 100644 --- a/app/client/mobile/src/message/imageAsset/ImageAsset.tsx +++ b/app/client/mobile/src/message/imageAsset/ImageAsset.tsx @@ -13,6 +13,7 @@ export function ImageAsset({ topicId, asset, loaded, show }: { topicId: string, const [modal, setModal] = useState(false); const opacity = useAnimatedValue(0); const [cleared, setCleared] = useState(false); + const [downloading, setDownloading] = useState(false); useEffect(() => { if (state.loaded && show) { @@ -38,6 +39,18 @@ export function ImageAsset({ topicId, asset, loaded, show }: { topicId: string, actions.cancelLoad(); } + const download = async () => { + if (!downloading) { + setDownloading(true); + try { + await actions.download(); + } catch (err) { + console.log(err); + } + setDownloading(false); + } + } + return ( { state.thumbUrl && ( @@ -81,7 +94,7 @@ export function ImageAsset({ topicId, asset, loaded, show }: { topicId: string, )} { state.dataUrl && ( - + )} diff --git a/app/client/mobile/src/message/videoAsset/VideoAsset.styled.ts b/app/client/mobile/src/message/videoAsset/VideoAsset.styled.ts index 23152d63..f0c380bb 100644 --- a/app/client/mobile/src/message/videoAsset/VideoAsset.styled.ts +++ b/app/client/mobile/src/message/videoAsset/VideoAsset.styled.ts @@ -53,7 +53,6 @@ export const styles = StyleSheet.create({ right: 0, }, closeIcon: { - backgroundColor: 'transparent', }, progress: { position: 'absolute', diff --git a/app/client/mobile/src/message/videoAsset/VideoAsset.tsx b/app/client/mobile/src/message/videoAsset/VideoAsset.tsx index 60e9f72d..96e2bcf3 100644 --- a/app/client/mobile/src/message/videoAsset/VideoAsset.tsx +++ b/app/client/mobile/src/message/videoAsset/VideoAsset.tsx @@ -16,6 +16,7 @@ export function VideoAsset({ topicId, asset, loaded, show }: { topicId: string, const [status, setStatus] = useState('loading'); const [showControl, setShowControl] = useState(false); const clear = useRef(); + const [downloading, setDownloading] = useState(false); useEffect(() => { if (state.loaded && show) { @@ -68,6 +69,18 @@ export function VideoAsset({ topicId, asset, loaded, show }: { topicId: string, } } + const download = async () => { + if (!downloading) { + setDownloading(true); + try { + await actions.download(); + } catch (err) { + console.log(err); + } + setDownloading(false); + } + } + return ( { state.thumbUrl && ( @@ -112,7 +125,7 @@ export function VideoAsset({ topicId, asset, loaded, show }: { topicId: string, )} { state.dataUrl && ( - + )}