mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
fixing race where shared intent not showing on sealed channel
This commit is contained in:
parent
82e15f5ec7
commit
245b05d192
@ -18,28 +18,30 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
|
||||
const { state, actions } = useAddTopic(contentKey);
|
||||
|
||||
useEffect(() => {
|
||||
if (shareIntent) {
|
||||
shareIntent.forEach(share => {
|
||||
if (share.text) {
|
||||
actions.setMessage(share.text);
|
||||
}
|
||||
if (share.weblink) {
|
||||
actions.setMessage(share.weblink);
|
||||
}
|
||||
const mime = share.mimeType?.toLowerCase();
|
||||
if (mime === '.jpg' || mime === '.png' || mime === 'image/jpeg' || mime == 'image/png' ) {
|
||||
actions.addImage(share.filePath)
|
||||
}
|
||||
if (mime === '.mp4' || mime === 'video/mp4' || mime == 'video/mpeg') {
|
||||
actions.addVideo(share.filePath)
|
||||
}
|
||||
if (mime === '.mp3') {
|
||||
actions.addAudio(share.filePath)
|
||||
}
|
||||
});
|
||||
setShareIntent(null);
|
||||
if (shareIntent && state.loaded) {
|
||||
if (!state.locked || contentKey) {
|
||||
shareIntent.forEach(share => {
|
||||
if (share.text) {
|
||||
actions.setMessage(share.text);
|
||||
}
|
||||
if (share.weblink) {
|
||||
actions.setMessage(share.weblink);
|
||||
}
|
||||
const mime = share.mimeType?.toLowerCase();
|
||||
if (mime === '.jpg' || mime === '.png' || mime === 'image/jpeg' || mime == 'image/png' ) {
|
||||
actions.addImage(share.filePath)
|
||||
}
|
||||
if (mime === '.mp4' || mime === 'video/mp4' || mime == 'video/mpeg') {
|
||||
actions.addVideo(share.filePath)
|
||||
}
|
||||
if (mime === '.mp3') {
|
||||
actions.addAudio(share.filePath)
|
||||
}
|
||||
});
|
||||
setShareIntent(null);
|
||||
}
|
||||
}
|
||||
}, [shareIntent]);
|
||||
}, [shareIntent, state.loaded, state.locked, contentKey]);
|
||||
|
||||
const addImage = async () => {
|
||||
try {
|
||||
|
@ -25,6 +25,7 @@ export function useAddTopic(contentKey) {
|
||||
enableAudio: false,
|
||||
enableVideo: false,
|
||||
locked: true,
|
||||
loaded: false,
|
||||
conflict: false,
|
||||
});
|
||||
|
||||
@ -100,11 +101,13 @@ export function useAddTopic(contentKey) {
|
||||
useEffect(() => {
|
||||
const { enableVideo, enableAudio, enableImage } = conversation.state.channel?.detail || {};
|
||||
const locked = conversation.state.channel?.detail?.dataType === 'superbasic' ? false : true;
|
||||
updateState({ enableImage, enableAudio, enableVideo, locked });
|
||||
const loaded = conversation.state.loaded;
|
||||
updateState({ enableImage, enableAudio, enableVideo, locked, loaded });
|
||||
}, [conversation.state]);
|
||||
|
||||
const setAsset = async (file, scale) => {
|
||||
const url = file.startsWith('file:') ? file : `file://${file}`;
|
||||
|
||||
if (contentKey) {
|
||||
const scaled = scale ? await scale(url) : url;
|
||||
const stat = await RNFS.stat(scaled);
|
||||
|
Loading…
Reference in New Issue
Block a user