diff --git a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx index 448be2d7..f1ee75ca 100644 --- a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx +++ b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx @@ -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 { diff --git a/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js b/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js index aa15022a..3f7e1804 100644 --- a/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js +++ b/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js @@ -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);