diff --git a/lib/src/entities/user.ts b/lib/src/entities/user.ts index cc86409..cd8b8e8 100644 --- a/lib/src/entities/user.ts +++ b/lib/src/entities/user.ts @@ -54,6 +54,7 @@ export class User { } get active() { + console.log("userid", this.id, new Date().getTime(), this.lastActiveTimestamp) return !!( this.lastActiveTimestamp && new Date().getTime() - this.lastActiveTimestamp <= this.chat.config.storeUserActivityInterval diff --git a/samples/react-native-group-chat/App.tsx b/samples/react-native-group-chat/App.tsx index 212f61f..7d604fa 100644 --- a/samples/react-native-group-chat/App.tsx +++ b/samples/react-native-group-chat/App.tsx @@ -121,9 +121,7 @@ function MainRoutesNavigator({ route }: StackScreenProps { return ( - navigation.navigate("PinnedMessage", { channelId: currentChannel?.id }) - } + onPress={() => navigation.navigate("PinnedMessage")} style={{ paddingRight: 24 }} > diff --git a/samples/react-native-group-chat/screens/ordinary/chat/Chat.tsx b/samples/react-native-group-chat/screens/ordinary/chat/Chat.tsx index ccaf211..a17423f 100644 --- a/samples/react-native-group-chat/screens/ordinary/chat/Chat.tsx +++ b/samples/react-native-group-chat/screens/ordinary/chat/Chat.tsx @@ -69,11 +69,6 @@ export function ChatScreen({}: StackScreenProps) { } await message.pin() - await currentChannel.update({ name: "Grupa chatowa 23" + Math.random() }) - // const refreshedChannel = await chat.getChannel(currentChannel.id) - // if (refreshedChannel) { - // setCurrentChannel(refreshedChannel) - // } }, [chat, currentChannel, setCurrentChannel] ) @@ -103,18 +98,6 @@ export function ChatScreen({}: StackScreenProps) { onToggleEmoji: handleEmoji, }) - useEffect(() => { - if (!currentChannel) { - return - } - console.log("hello", currentChannel) - const unstream = currentChannel.streamUpdates((ch) => { - console.log("ch", ch) - }) - - return unstream - }, [currentChannel]) - useEffect(() => { if (!giftedChatMappedMessages.length) { return diff --git a/samples/react-native-group-chat/screens/ordinary/pinned-message/PinnedMessage.tsx b/samples/react-native-group-chat/screens/ordinary/pinned-message/PinnedMessage.tsx index bf0aa8e..df64e87 100644 --- a/samples/react-native-group-chat/screens/ordinary/pinned-message/PinnedMessage.tsx +++ b/samples/react-native-group-chat/screens/ordinary/pinned-message/PinnedMessage.tsx @@ -16,12 +16,23 @@ export function PinnedMessage({}: StackScreenProps { async function init() { if (!chat || !currentChannel) return - setMessage(await currentChannel.getPinnedMessage()) + const refreshedChannel = await chat.getChannel(currentChannel.id) + if (refreshedChannel) { + setMessage(await refreshedChannel.getPinnedMessage()) + } } init() }, [chat, currentChannel]) + useEffect(() => { + const unstream = currentChannel?.streamUpdates(async (channel) => { + setMessage(await channel.getPinnedMessage()) + }) + + return unstream + }, [currentChannel]) + const renderMessageBubble = useCallback( (props: Bubble["props"]) => { if (!message) {