frontend client for gemstone. decentralised workplace app
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: don't throw on invalid session

serenity 0f91f36f 1f0b7387

+25 -17
+7 -5
src/components/Chat/index.tsx
··· 13 13 14 14 export const Chat = ({ channelAtUri }: { channelAtUri: AtUri }) => { 15 15 const [inputText, setInputText] = useState(""); 16 - const { messages, sendMessageToChannel, isConnected } = 17 - useChannel(channelAtUri); 18 16 const record = useChannelRecordByAtUriObject(channelAtUri); 19 17 const { semantic } = useCurrentPalette(); 20 18 const { typography, atoms } = useFacet(); 19 + const channel = useChannel(channelAtUri); 20 + const { isLoading } = useProfile(); 21 + 22 + if (!channel) return <></>; 23 + 24 + const { messages, sendMessageToChannel, isConnected } = channel; 21 25 22 26 const handleSend = () => { 23 27 if (inputText.trim()) { ··· 26 30 } 27 31 }; 28 32 29 - const { isLoading } = useProfile(); 30 - 31 33 if (!record) 32 34 return ( 33 35 <View> 34 36 <Text> 35 - Something has gone wrong. Could not resolve channel record 37 + Something has gone wrong.Could not resolve channel record 36 38 from given at:// URI. 37 39 </Text> 38 40 </View>
+17 -9
src/lib/hooks/useChannel.ts
··· 20 20 const { sessionInfo, socket } = findChannelSession(channel); 21 21 22 22 useEffect(() => { 23 - if (!sessionInfo) 24 - throw new Error( 23 + if (!sessionInfo) { 24 + console.warn( 25 25 "Channel did not resolve to a valid sessionInfo object.", 26 26 ); 27 - if (!socket) 28 - throw new Error( 27 + return; 28 + } 29 + if (!socket) { 30 + console.warn( 29 31 "Session info did not resolve to a valid websocket connection. This should not happen and is likely a bug. Check the sessions map object.", 30 32 ); 33 + return; 34 + } 31 35 32 36 // attach handlers here 33 37 ··· 117 121 }; 118 122 }, [socket, sessionInfo, channel]); 119 123 120 - if (!oAuthSession) throw new Error("No OAuth session"); 121 - if (!sessionInfo) 122 - throw new Error( 124 + if (!oAuthSession) {console.warn("No OAuth session"); return } 125 + if (!sessionInfo) { 126 + console.warn( 123 127 "Channel did not resolve to a valid sessionInfo object.", 124 128 ); 125 - if (!socket) 126 - throw new Error( 129 + return; 130 + } 131 + if (!socket) { 132 + console.warn( 127 133 "Session info did not resolve to a valid websocket connection. This should not happen and is likely a bug. Check the sessions map object.", 128 134 ); 135 + return; 136 + } 129 137 130 138 const channelStringified = atUriToString(channel); 131 139
+1 -3
src/providers/authed/SessionsProvider.tsx
··· 98 98 99 99 console.log("tried to find", channel); 100 100 if (!sessionInfo) 101 - throw new Error( 102 - "Provided channel at:// URI (object) could not be found in any existing lattice sessions", 103 - ); 101 + return { sessionInfo: undefined, socket: undefined }; 104 102 105 103 return { sessionInfo, socket: sessionsMap.get(sessionInfo) }; 106 104 },