|
@@ -1,7 +1,9 @@
|
|
|
-import { FC, useMemo } from 'react'
|
|
|
|
|
|
|
+import { FC, useEffect, useMemo, useRef } from 'react'
|
|
|
import { useFileTreePathContext } from '@/features/file-tree/contexts/file-tree-path'
|
|
import { useFileTreePathContext } from '@/features/file-tree/contexts/file-tree-path'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
|
|
|
|
+import { sendMB } from '@/infrastructure/event-tracking'
|
|
|
|
|
+import { useConnectionContext } from '@/features/ide-react/context/connection-context'
|
|
|
|
|
|
|
|
const MAX_UNSAVED_ALERT_SECONDS = 15
|
|
const MAX_UNSAVED_ALERT_SECONDS = 15
|
|
|
|
|
|
|
@@ -23,8 +25,21 @@ const UnsavedDocAlert: FC<{ docId: string; seconds: number }> = ({
|
|
|
seconds,
|
|
seconds,
|
|
|
}) => {
|
|
}) => {
|
|
|
const { pathInFolder, findEntityByPath } = useFileTreePathContext()
|
|
const { pathInFolder, findEntityByPath } = useFileTreePathContext()
|
|
|
|
|
+ const { socket } = useConnectionContext()
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
|
|
+ const recordedRef = useRef(false)
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (!recordedRef.current) {
|
|
|
|
|
+ recordedRef.current = true
|
|
|
|
|
+ sendMB('unsaved-doc-alert-shown', {
|
|
|
|
|
+ docId,
|
|
|
|
|
+ transport: socket.socket.transport?.name,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [docId, socket])
|
|
|
|
|
+
|
|
|
const doc = useMemo(() => {
|
|
const doc = useMemo(() => {
|
|
|
const path = pathInFolder(docId)
|
|
const path = pathInFolder(docId)
|
|
|
return path ? findEntityByPath(path) : null
|
|
return path ? findEntityByPath(path) : null
|