|
@@ -114,8 +114,12 @@ const MessagesScreen = () => {
|
|
|
};
|
|
|
|
|
|
socket.current.onmessage = (event) => {
|
|
|
- const data = JSON.parse(event.data);
|
|
|
- handleWebSocketMessage(data);
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(event.data);
|
|
|
+ handleWebSocketMessage(data);
|
|
|
+ } catch {
|
|
|
+ console.log('Invalid WS message:', event.data);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
socket.current.onclose = () => {
|
|
@@ -154,8 +158,12 @@ const MessagesScreen = () => {
|
|
|
socket.current?.send(JSON.stringify({ token }));
|
|
|
};
|
|
|
socket.current.onmessage = (event) => {
|
|
|
- const data = JSON.parse(event.data);
|
|
|
- handleWebSocketMessage(data);
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(event.data);
|
|
|
+ handleWebSocketMessage(data);
|
|
|
+ } catch {
|
|
|
+ console.log('Invalid WS message:', event.data);
|
|
|
+ }
|
|
|
};
|
|
|
}
|
|
|
}
|
|
@@ -357,29 +365,19 @@ const MessagesScreen = () => {
|
|
|
activeOpacity={0.8}
|
|
|
onPress={() => {
|
|
|
if (!item.uid) {
|
|
|
- navigation.navigate(
|
|
|
- ...([
|
|
|
- NAVIGATION_PAGES.GROUP_CHAT,
|
|
|
- {
|
|
|
- group_token: item.group_chat_token,
|
|
|
- name: item.name,
|
|
|
- avatar: item.avatar,
|
|
|
- userType: item.user_type
|
|
|
- }
|
|
|
- ] as never)
|
|
|
- );
|
|
|
+ navigation.navigate(NAVIGATION_PAGES.GROUP_CHAT, {
|
|
|
+ group_token: item.group_chat_token,
|
|
|
+ name: item.name,
|
|
|
+ avatar: item.avatar,
|
|
|
+ userType: item.user_type
|
|
|
+ });
|
|
|
} else {
|
|
|
- navigation.navigate(
|
|
|
- ...([
|
|
|
- NAVIGATION_PAGES.CHAT,
|
|
|
- {
|
|
|
- id: item.uid,
|
|
|
- name: item.name,
|
|
|
- avatar: item.avatar,
|
|
|
- userType: item.user_type
|
|
|
- }
|
|
|
- ] as never)
|
|
|
- );
|
|
|
+ navigation.navigate(NAVIGATION_PAGES.CHAT, {
|
|
|
+ id: item.uid,
|
|
|
+ name: item.name,
|
|
|
+ avatar: item.avatar,
|
|
|
+ userType: item.user_type
|
|
|
+ });
|
|
|
}
|
|
|
}}
|
|
|
underlayColor={Colors.FILL_LIGHT}
|
|
@@ -484,9 +482,7 @@ const MessagesScreen = () => {
|
|
|
<TouchableHighlight
|
|
|
activeOpacity={0.8}
|
|
|
onPress={() =>
|
|
|
- navigation.navigate(
|
|
|
- ...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: item.id }] as never)
|
|
|
- )
|
|
|
+ navigation.navigate(NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: item.id })
|
|
|
}
|
|
|
underlayColor={Colors.FILL_LIGHT}
|
|
|
>
|