Skip to content

Commit a2805b0

Browse files
committed
refactor: remove outdated/invalid code from vite example App.tsx
1 parent 298a371 commit a2805b0

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

examples/vite/src/App.tsx

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
ChannelSort,
66
LocalMessage,
77
TextComposerMiddleware,
8-
LiveLocationManagerConstructorParameters,
98
} from 'stream-chat';
109
import {
1110
AIStateIndicator,
@@ -21,8 +20,6 @@ import {
2120
useCreateChatClient,
2221
VirtualizedMessageList as MessageList,
2322
Window,
24-
useChatContext,
25-
useLiveLocationSharingManager,
2623
} from 'stream-chat-react';
2724
import { createTextComposerEmojiMiddleware, EmojiPicker } from 'stream-chat-react/emojis';
2825
import { init, SearchIndex } from 'emoji-mart';
@@ -57,73 +54,13 @@ const sort: ChannelSort = { pinned_at: 1, last_message_at: -1, updated_at: -1 };
5754
// @ts-ignore
5855
const isMessageAIGenerated = (message: LocalMessage) => !!message?.ai_generated;
5956

60-
const ShareLiveLocation = () => {
61-
const { channel } = useChatContext();
62-
63-
return (
64-
<button
65-
onClick={() => {
66-
console.log('trying to fetch location');
67-
navigator.geolocation.getCurrentPosition(
68-
(position) => {
69-
const { latitude, longitude } = position.coords;
70-
console.log('got location ', position);
71-
channel?.startLiveLocationSharing({
72-
latitude,
73-
longitude,
74-
end_time: new Date(Date.now() + 1 * 1000 * 3600 * 24).toISOString(),
75-
});
76-
},
77-
console.warn,
78-
{ timeout: 2000 },
79-
);
80-
}}
81-
>
82-
location
83-
</button>
84-
);
85-
};
86-
87-
const watchLocationNormal: LiveLocationManagerConstructorParameters['watchLocation'] = (
88-
watcher,
89-
) => {
90-
const watch = navigator.geolocation.watchPosition((position) => {
91-
watcher({ latitude: position.coords.latitude, longitude: position.coords.longitude });
92-
});
93-
94-
return () => navigator.geolocation.clearWatch(watch);
95-
};
96-
97-
const watchLocationTimed: LiveLocationManagerConstructorParameters['watchLocation'] = (
98-
watcher,
99-
) => {
100-
const timer = setInterval(() => {
101-
navigator.geolocation.getCurrentPosition((position) => {
102-
watcher({
103-
latitude: position.coords.latitude,
104-
longitude: position.coords.longitude,
105-
});
106-
});
107-
}, 5000);
108-
109-
return () => {
110-
clearInterval(timer);
111-
console.log('cleanup');
112-
};
113-
};
114-
11557
const App = () => {
11658
const chatClient = useCreateChatClient({
11759
apiKey,
11860
tokenOrProvider: userToken,
11961
userData: { id: userId },
12062
});
12163

122-
useLiveLocationSharingManager({
123-
client: chatClient,
124-
watchLocation: watchLocationNormal,
125-
});
126-
12764
useEffect(() => {
12865
if (!chatClient) return;
12966

@@ -159,7 +96,6 @@ const App = () => {
15996
<MessageList returnAllReadData />
16097
<AIStateIndicator />
16198
<MessageInput focus audioRecordingEnabled />
162-
<ShareLiveLocation />
16399
</Window>
164100
<Thread virtualized />
165101
</Channel>

0 commit comments

Comments
 (0)