1 line
5.2 KiB
Plaintext
1 line
5.2 KiB
Plaintext
{"version":3,"file":"compose-Gtwe4AUy.js","sources":["../../src/compose.jsx"],"sourcesContent":["import './index.css';\nimport './app.css';\nimport './polyfills';\n\nimport { i18n } from '@lingui/core';\nimport { t, Trans } from '@lingui/macro';\nimport { I18nProvider } from '@lingui/react';\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, setCurrentAccountID } 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 [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","uiState","setUIState","useState","isLoggedIn","setIsLoggedIn","editStatus","replyToStatus","draftStatus","__COMPOSE__","useTitle","i18n","_","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"],"mappings":"mIAiBAA,IAEIC,OAAOC,SACTC,QAAUF,OAAOC,OAAOC,SAG1B,SAASC,GAAM,SACb,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAS,SAAS,EAC1C,CAACC,EAAYC,CAAa,EAAIF,EAAS,IAAI,EAE3C,CAAEG,WAAAA,EAAYC,cAAAA,EAAeC,YAAAA,CAAAA,EAAgBX,OAAOY,aAAe,GA8BzE,OA5BAC,EACEJ,EAAUK,EAAAC,EACN,CAAAC,GAAA,QAAuB,CAAA,EACvBN,EAAaI,EAAAC,EACb,CAAAC,GAAA,SAAAC,OAAA,CAAAC,IACER,EAAAA,EAAcS,UAAdT,YAAAA,EAAuBU,SAAQV,EAAAA,EAAcS,UAAdT,YAAAA,EAAuBW,SAAQ,CAC/D,GAACP,EAAAC,EACF,CAAAC,GAAA,QAAS,CAAA,CACf,EAEAM,EAAU,IAAM,CACd,MAAMH,EAAUI,IACFf,EAAA,CAAC,CAACW,CAAO,EACnBA,GACSK,GAEf,EAAG,CAAE,CAAA,EAELF,EAAU,IAAM,CACd,GAAIlB,IAAY,SAAU,CACpB,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