diff --git a/app/mobile/src/context/useAppContext.hook.js b/app/mobile/src/context/useAppContext.hook.js index 6e5ea107..9126aebb 100644 --- a/app/mobile/src/context/useAppContext.hook.js +++ b/app/mobile/src/context/useAppContext.hook.js @@ -21,6 +21,7 @@ export function useAppContext() { const profile = useContext(ProfileContext); const card = useContext(CardContext); const channel = useContext(ChannelContext); + const count = useRef(0); const ws = useRef(null); @@ -101,14 +102,17 @@ export function useAppContext() { catch(err) { console.log(err); } - updateState({ disconnected: 0 }); + count.current = 0; + updateState({ disconnected: count.current }); } catch (err) { console.log(err); } } ws.current.onclose = (e) => { - updateState({ disconnected: state.disconnected + 1 }); + count.current += 1; +console.log("CURRENT1: ", count.current); + updateState({ disconnected: count.current }); console.log(e) setTimeout(() => { if (ws.current != null) { @@ -124,7 +128,9 @@ export function useAppContext() { ws.current.send(JSON.stringify({ AppToken: token })) } ws.current.error = (e) => { - updateState({ disconnected: state.disconnected + 1 }); + count.current += 1; +console.log("CURRENT2: ", count.current); + updateState({ disconnected: count.current }); console.log(e) } } diff --git a/app/mobile/src/session/conversation/topicItem/imageAsset/ImageAsset.jsx b/app/mobile/src/session/conversation/topicItem/imageAsset/ImageAsset.jsx index bac84635..fb3df394 100644 --- a/app/mobile/src/session/conversation/topicItem/imageAsset/ImageAsset.jsx +++ b/app/mobile/src/session/conversation/topicItem/imageAsset/ImageAsset.jsx @@ -8,8 +8,14 @@ export function ImageAsset({ topicId, asset, dismiss }) { return ( - - { !state.loaded && ( + + { state.failed && ( + + + + )} + { !state.loaded && !state.failed && ( diff --git a/app/mobile/src/session/conversation/topicItem/imageAsset/useImageAsset.hook.js b/app/mobile/src/session/conversation/topicItem/imageAsset/useImageAsset.hook.js index ffa5eda7..52beb82b 100644 --- a/app/mobile/src/session/conversation/topicItem/imageAsset/useImageAsset.hook.js +++ b/app/mobile/src/session/conversation/topicItem/imageAsset/useImageAsset.hook.js @@ -13,6 +13,7 @@ export function useImageAsset(topicId, asset) { imageHeight: 1, url: null, loaded: false, + failed: false, }); const conversation = useContext(ConversationContext); @@ -44,17 +45,17 @@ export function useImageAsset(topicId, asset) { useEffect(() => { const url = conversation.actions.getTopicAssetUrl(topicId, asset.full); - if (url) { - Image.getSize(url, (width, height) => { - updateState({ url, imageRatio: width / height }); - }); - } + updateState({ url }); }, [topicId, conversation, asset]); const actions = { - loaded: () => { - updateState({ loaded: true }); - } + loaded: (e) => { + const { width, height } = e.nativeEvent.source; + updateState({ loaded: true, imageRatio: width / height }); + }, + failed: () => { + updateState({ failed: true }); + }, }; return { state, actions };