import type { FC } from '../../../lib/teact/teact'; import React, { memo, useCallback, useEffect, useState, } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; import { DEBUG_LOG_FILENAME } from '../../../config'; import { getDebugLogs } from '../../../util/debugConsole'; import download from '../../../util/download'; import { IS_ELECTRON } from '../../../util/windowEnvironment'; import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets'; import useHistoryBack from '../../../hooks/useHistoryBack'; import useLang from '../../../hooks/useLang'; import useLastCallback from '../../../hooks/useLastCallback'; import AnimatedIcon from '../../common/AnimatedIcon'; import Checkbox from '../../ui/Checkbox'; import ListItem from '../../ui/ListItem'; type OwnProps = { isActive?: boolean; onReset: () => void; }; type StateProps = { shouldShowLoginCodeInChatList?: boolean; shouldForceHttpTransport?: boolean; shouldAllowHttpTransport?: boolean; shouldCollectDebugLogs?: boolean; shouldDebugExportedSenders?: boolean; }; const SettingsExperimental: FC = ({ isActive, onReset, shouldShowLoginCodeInChatList, shouldForceHttpTransport, shouldAllowHttpTransport, shouldCollectDebugLogs, shouldDebugExportedSenders, }) => { const { requestConfetti, setSettingOption } = getActions(); const lang = useLang(); const [isAutoUpdateEnabled, setIsAutoUpdateEnabled] = useState(false); useEffect(() => { window.electron?.getIsAutoUpdateEnabled().then(setIsAutoUpdateEnabled); }, []); useHistoryBack({ isActive, onBack: onReset, }); const handleDownloadLog = useLastCallback(() => { const file = new File([getDebugLogs()], DEBUG_LOG_FILENAME, { type: 'text/plain' }); const url = URL.createObjectURL(file); download(url, DEBUG_LOG_FILENAME); }); const handleIsAutoUpdateEnabledChange = useCallback((isChecked: boolean) => { window.electron?.setIsAutoUpdateEnabled(isChecked); }, []); return (

{lang('lng_settings_experimental_about')}

requestConfetti({})} icon="animations" >
Launch some confetti!
setSettingOption({ shouldShowLoginCodeInChatList: !shouldShowLoginCodeInChatList })} /> setSettingOption({ shouldAllowHttpTransport: !shouldAllowHttpTransport })} /> setSettingOption({ shouldForceHttpTransport: !shouldForceHttpTransport })} /> setSettingOption({ shouldCollectDebugLogs: !shouldCollectDebugLogs })} /> setSettingOption({ shouldDebugExportedSenders: !shouldDebugExportedSenders })} /> {IS_ELECTRON && ( )}
Download log
); }; export default memo(withGlobal( (global): StateProps => { return { shouldShowLoginCodeInChatList: global.settings.byKey.shouldShowLoginCodeInChatList, shouldForceHttpTransport: global.settings.byKey.shouldForceHttpTransport, shouldAllowHttpTransport: global.settings.byKey.shouldAllowHttpTransport, shouldCollectDebugLogs: global.settings.byKey.shouldCollectDebugLogs, shouldDebugExportedSenders: global.settings.byKey.shouldDebugExportedSenders, }; }, )(SettingsExperimental));