// Metro module 11524 (f11525). import { useRef, useEffect } from "react"; import LocaleStore from "../user_settings/LocaleStore"; import ReadStateStore from "../../stores/ReadStateStore"; import ChangelogStore from "./ChangelogStore"; import { AnalyticEvents } from "../../Constants"; import useChangelogIdFromChannel from "./useChangelogIdFromChannel"; import { useStateFromStores } from "../../_bundle/Module589"; import isChangelogChannel from "./utils/isChangelogChannel"; import ChangeLogActionCreators from "../../actions/ChangeLogActionCreators"; import AnalyticsUtils from "../../utils/AnalyticsUtils"; export default function useChangelogRenderedAnalytics(a0) { let stateFromStores2, c18932_4, ref, stateFromStores3, ref2; const changelogIdFromChannel = useChangelogIdFromChannel(a0); let c18932_1 = changelogIdFromChannel; const stateFromStores = useStateFromStores([LocaleStore], () => LocaleStore.locale); stateFromStores2 = useStateFromStores([ChangelogStore], () => { let r5 = c18932_1; if (r5 == null) { r5 = ""; } return ChangelogStore.getChangelog(r5, stateFromStores); }, [changelogIdFromChannel, stateFromStores]); const isChangelogChannel2 = isChangelogChannel(a0); c18932_4 = isChangelogChannel2; ref = useRef(isChangelogChannel2 ? Date.now() : null); stateFromStores3 = useStateFromStores([ReadStateStore], () => ReadStateStore.getUnreadCount(a0), [a0]); ref2 = useRef(stateFromStores3); useEffect(() => { ref2.current = stateFromStores3; }); useEffect(() => { ref.current = Date.now(); }, [isChangelogChannel2]); useEffect(() => { if (c18932_4 && c18932_1 != null) { ChangeLogActionCreators.fetchChangelog(c18932_1, stateFromStores, true); } }, [changelogIdFromChannel, stateFromStores, isChangelogChannel2]); useEffect(() => { if (c18932_4 && stateFromStores2 != null) { AnalyticsUtils.track(AnalyticEvents.CHANGE_LOG_OPENED, { change_log_id: `${stateFromStores2.date}:${stateFromStores2.revision}`, unread_count: ref2.current }); } }, [isChangelogChannel2, stateFromStores2]); useEffect(() => { const current = ref.current; return () => { if (c18932_4 && stateFromStores2 != null && current != null) { AnalyticsUtils.track(AnalyticEvents.CHANGE_LOG_CLOSED, { seconds_open: Math.round((Date.now() - current) / 1000), change_log_id: `${stateFromStores2.date}:${stateFromStores2.revision}`, unread_count: ref2.current }); ref.current = 0; } }; }, [isChangelogChannel2, stateFromStores2]); };