fixing race where shared intent not showing on sealed channel

This commit is contained in:
balzack 2023-05-05 22:08:19 -07:00
parent 82e15f5ec7
commit 245b05d192
2 changed files with 27 additions and 22 deletions

View File

@ -18,7 +18,8 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
const { state, actions } = useAddTopic(contentKey);
useEffect(() => {
if (shareIntent) {
if (shareIntent && state.loaded) {
if (!state.locked || contentKey) {
shareIntent.forEach(share => {
if (share.text) {
actions.setMessage(share.text);
@ -39,7 +40,8 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
});
setShareIntent(null);
}
}, [shareIntent]);
}
}, [shareIntent, state.loaded, state.locked, contentKey]);
const addImage = async () => {
try {

View File

@ -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);