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