1 line
5.2 KiB
Plaintext
1 line
5.2 KiB
Plaintext
{"version":3,"file":"compose-_EXIhB02.js","sources":["../../src/compose.jsx"],"sourcesContent":["import './index.css';\nimport './app.css';\nimport './polyfills';\n\nimport { i18n } from '@lingui/core';\nimport { I18nProvider } from '@lingui/react';\nimport { Trans, useLingui } from '@lingui/react/macro';\nimport { render } from 'preact';\nimport { useEffect, useState } from 'preact/hooks';\n\nimport ComposeSuspense from './components/compose-suspense';\nimport Loader from './components/loader';\nimport { initActivateLang } from './utils/lang';\nimport { initStates } from './utils/states';\nimport { getCurrentAccount } from './utils/store-utils';\nimport useTitle from './utils/useTitle';\n\ninitActivateLang();\n\nif (window.opener) {\n console = window.opener.console;\n}\n\nfunction App() {\n const { t } = useLingui();\n const [uiState, setUIState] = useState('default');\n const [isLoggedIn, setIsLoggedIn] = useState(null);\n\n const { editStatus, replyToStatus, draftStatus } = window.__COMPOSE__ || {};\n\n useTitle(\n editStatus\n ? t`Editing source status`\n : replyToStatus\n ? t`Replying to @${\n replyToStatus.account?.acct || replyToStatus.account?.username\n }`\n : t`Compose`,\n );\n\n useEffect(() => {\n const account = getCurrentAccount();\n setIsLoggedIn(!!account);\n if (account) {\n initStates();\n }\n }, []);\n\n useEffect(() => {\n if (uiState === 'closed') {\n try {\n // Focus parent window\n window.opener.focus();\n } catch (e) {}\n window.close();\n }\n }, [uiState]);\n\n if (uiState === 'closed') {\n return (\n <div class=\"box\">\n <p>\n <Trans>You may close this page now.</Trans>\n </p>\n <p>\n <button\n onClick={() => {\n window.close();\n }}\n >\n <Trans>Close window</Trans>\n </button>\n </p>\n </div>\n );\n }\n\n console.debug('OPEN COMPOSE');\n\n if (isLoggedIn === false) {\n return (\n <div class=\"box\">\n <h1>\n <Trans>Error</Trans>\n </h1>\n <p>\n <Trans>Login required.</Trans>\n </p>\n <p>\n <a href=\"/\">\n <Trans>Go home</Trans>\n </a>\n </p>\n </div>\n );\n }\n\n if (isLoggedIn) {\n return (\n <ComposeSuspense\n editStatus={editStatus}\n replyToStatus={replyToStatus}\n draftStatus={draftStatus}\n standalone\n hasOpener={window.opener}\n onClose={(results) => {\n const { newStatus, fn = () => {} } = results || {};\n try {\n if (newStatus) {\n window.opener.__STATES__.reloadStatusPage++;\n }\n fn();\n setUIState('closed');\n } catch (e) {}\n }}\n />\n );\n }\n\n return (\n <div class=\"box\">\n <Loader />\n </div>\n );\n}\n\nrender(\n <I18nProvider i18n={i18n}>\n <App />\n </I18nProvider>,\n document.getElementById('app-standalone'),\n);\n"],"names":["initActivateLang","window","opener","console","App","t","_useLingui","uiState","setUIState","useState","isLoggedIn","setIsLoggedIn","editStatus","replyToStatus","draftStatus","__COMPOSE__","useTitle","_t","id","values","0","account","acct","username","useEffect","getCurrentAccount","initStates","focus","close","_jsxs","class","children","_jsx","_Trans","onClick","href","ComposeSuspense","standalone","hasOpener","newStatus","results","fn","Loader","render","I18nProvider","i18n"],"mappings":"0IAiBAA,IAEIC,OAAOC,SACTC,QAAUF,OAAOC,OAAOC,SAG1B,SAASC,GAAM,SACP,KAAA,CAAEC,EAAAA,GAAGC,EAAc,EACnB,CAACC,EAASC,CAAU,EAAIC,EAAS,SAAS,EAC1C,CAACC,EAAYC,CAAa,EAAIF,EAAS,IAAI,EAE3C,CAAEG,WAAAA,EAAYC,cAAAA,EAAeC,YAAAA,CAAAA,EAAgBb,OAAOc,aAAe,GA8BzE,OA5BAC,EACYC,EAAVL,EACI,CAAAM,GAAA,QAAuB,EACvBL,EACE,CAAAK,GAAA,SAAAC,OAAA,CAAAC,IACEP,EAAAA,EAAcQ,UAAdR,YAAAA,EAAuBS,SAAQT,EAAAA,EAAcQ,UAAdR,YAAAA,EAAuBU,SAAQ,CAC/D,EACD,CAAAL,GAAA,QAAS,EACjB,EAEAM,EAAU,IAAM,CACd,MAAMH,EAAUI,IACFd,EAAA,CAAC,CAACU,CAAO,EACnBA,GACSK,GAEf,EAAG,CAAE,CAAA,EAELF,EAAU,IAAM,CACd,GAAIjB,IAAY,SAA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