pinafore/src/routes/share.html
Nolan Lawson 038dc27163
perf: lazy-load computations (#1538)
* perf: lazy-load computations (experimental)

* fix lint

* add marks

* fixup

* lazy-load mixins too

* add missing files

* fix tests
2019-09-26 05:23:36 -07:00

30 lines
922 B
HTML

<!-- this is just used for the web share target API -->
<script>
import { store } from './_store/store'
import { goto } from '../../__sapper__/client'
import { decodeURIComponentWithPluses } from './_utils/decodeURIComponentWithPluses'
import { importLoggedInStoreExtensions } from './_utils/asyncModules'
const SHARE_KEYS = ['title', 'text', 'url']
export default {
store: () => store,
async oncreate () {
const params = new URLSearchParams(location.search)
const text = SHARE_KEYS
.map(key => params.get(key) && decodeURIComponentWithPluses(params.get(key)))
.filter(Boolean)
.join(' ')
await importLoggedInStoreExtensions()
this.store.set({ openShareDialog: true })
this.store.clearComposeData('dialog')
this.store.setComposeData('dialog', { text })
this.store.save()
goto('/', { replaceState: true })
}
}
</script>