;
+}) => {
+ const { channel } = useChatContext();
+ const { isMyMessage, message } = useMessageContext();
+
+ const stoppedSharing = !!attachment.stopped_sharing;
+ const expired: boolean =
+ typeof attachment.end_time === 'string' && Date.now() > new Date(attachment.end_time).getTime();
+
+ return (
+
+ {attachment.type === 'live_location' && !stoppedSharing && !expired && isMyMessage() && (
+
+ )}
+ {/* TODO: {MAP} */}
+
+ lat: {attachment.latitude}, lng: {attachment.longitude}
+
+ {(stoppedSharing || expired) && Location sharing ended}
+
+ );
+};
diff --git a/src/components/Attachment/hooks/useLiveLocationSharingManager.ts b/src/components/Attachment/hooks/useLiveLocationSharingManager.ts
new file mode 100644
index 0000000000..22270f2d6c
--- /dev/null
+++ b/src/components/Attachment/hooks/useLiveLocationSharingManager.ts
@@ -0,0 +1,37 @@
+import { LiveLocationManager } from 'stream-chat';
+import { useEffect, useMemo } from 'react';
+import type {
+ ExtendableGenerics,
+ LiveLocationManagerConstructorParameters,
+ StreamChat,
+} from 'stream-chat';
+
+export const useLiveLocationSharingManager = ({
+ client,
+ retrieveAndDeserialize,
+ serializeAndStore,
+ watchLocation,
+}: Omit, 'client'> & {
+ client?: StreamChat | null;
+}) => {
+ const manager = useMemo(() => {
+ if (!client) return null;
+
+ return new LiveLocationManager({
+ client,
+ retrieveAndDeserialize,
+ serializeAndStore,
+ watchLocation,
+ });
+ }, [client, retrieveAndDeserialize, serializeAndStore, watchLocation]);
+
+ useEffect(() => {
+ if (!manager) return;
+
+ manager.registerSubscriptions();
+
+ return () => manager.unregisterSubscriptions();
+ }, [manager]);
+
+ return manager;
+};
diff --git a/src/components/Attachment/index.ts b/src/components/Attachment/index.ts
index f1385fe7d5..31fce5f014 100644
--- a/src/components/Attachment/index.ts
+++ b/src/components/Attachment/index.ts
@@ -8,3 +8,4 @@ export * from './components';
export * from './UnsupportedAttachment';
export * from './FileAttachment';
export * from './utils';
+export * from './hooks/useLiveLocationSharingManager';