mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 01:55:17 +00:00
abort transfer on close
This commit is contained in:
parent
68e4492402
commit
e5ae6e4a32
@ -25,7 +25,7 @@ export class MediaFiles implements Media {
|
||||
const close = async () => {
|
||||
await RNFS.unlink(path);
|
||||
}
|
||||
return { setData, getUrl };
|
||||
return { setData, getUrl, close };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ export function Message({ topic, card, profile, host, select, selected }: { topi
|
||||
</View>
|
||||
</Pressable>
|
||||
<View style={styles.padding}>
|
||||
{! locked && status === 'confirmed' && editing && (
|
||||
{ !locked && status === 'confirmed' && editing && (
|
||||
<View style={styles.editing}>
|
||||
</View>
|
||||
)}
|
||||
@ -77,7 +77,7 @@ export function Message({ topic, card, profile, host, select, selected }: { topi
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{ assets?.length > 0 && (
|
||||
{ !locked && assets?.length > 0 && (
|
||||
<ScrollView horizontal={true} showsHorizontalScrollIndicator={false} style={styles.carousel} contentContainerStyle={styles.assets}>
|
||||
{ media }
|
||||
</ScrollView>
|
||||
|
@ -28,7 +28,7 @@ export function ImageAsset({ topicId, asset }: { topicId: string, asset: MediaAs
|
||||
|
||||
const hideImage = () => {
|
||||
setModal(false);
|
||||
actions.unloadImage();
|
||||
actions.cancelLoad();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useState, useContext, useEffect } from 'react'
|
||||
import { useState, useContext, useEffect, useRef } from 'react'
|
||||
import { AppContext } from '../../context/AppContext'
|
||||
import { Focus } from 'databag-client-sdk'
|
||||
import { ContextType } from '../../context/ContextType'
|
||||
@ -14,6 +14,7 @@ export function useImageAsset(topicId: string, asset: MediaAsset) {
|
||||
loaded: false,
|
||||
loadPercent: 0,
|
||||
})
|
||||
const cancelled = useRef(false);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const updateState = (value: any) => {
|
||||
@ -42,16 +43,17 @@ export function useImageAsset(topicId: string, asset: MediaAsset) {
|
||||
const { width, height } = e.nativeEvent.source;
|
||||
updateState({ loaded: true, ratio: width / height });
|
||||
},
|
||||
unloadImage: () => {
|
||||
updateState({ dataUrl: null });
|
||||
cancelLoad: () => {
|
||||
cancelled.current = true;
|
||||
},
|
||||
loadImage: async () => {
|
||||
const { focus } = app.state;
|
||||
const assetId = asset.image ? asset.image.full : asset.encrypted ? asset.encrypted.parts : null;
|
||||
if (focus && assetId != null && !state.loading) {
|
||||
if (focus && assetId != null && !state.loading && !state.dataUrl) {
|
||||
cancelled.current = false;
|
||||
updateState({ loading: true, loadPercent: 0 });
|
||||
try {
|
||||
const dataUrl = await focus.getTopicAssetUrl(topicId, assetId, (loadPercent: number)=>{ updateState({ loadPercent }) });
|
||||
const dataUrl = await focus.getTopicAssetUrl(topicId, assetId, (loadPercent: number)=>{ updateState({ loadPercent }); return !cancelled.current });
|
||||
updateState({ dataUrl });
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
|
@ -941,8 +941,6 @@ export class FocusModule implements Focus {
|
||||
}
|
||||
|
||||
public async setChannelKey(cardId: string | null, channelId: string, channelKey: string | null) {
|
||||
console.log("!!!! SET CHANNEL KEY", cardId, channelId, channelKey);
|
||||
|
||||
if (cardId === this.cardId && channelId === this.channelId) {
|
||||
this.channelKey = channelKey;
|
||||
this.unsealAll = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user