2019-02-14 02:38:44 +00:00
|
|
|
<!-- 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'
|
|
|
|
|
|
|
|
const SHARE_KEYS = ['title', 'text', 'url']
|
|
|
|
|
|
|
|
export default {
|
|
|
|
store: () => store,
|
|
|
|
oncreate () {
|
2019-08-03 20:49:37 +00:00
|
|
|
const params = new URLSearchParams(location.search)
|
2019-02-14 02:38:44 +00:00
|
|
|
|
2019-08-03 20:49:37 +00:00
|
|
|
const text = SHARE_KEYS
|
2019-02-14 02:38:44 +00:00
|
|
|
.map(key => params.get(key) && decodeURIComponentWithPluses(params.get(key)))
|
|
|
|
.filter(Boolean)
|
|
|
|
.join(' ')
|
|
|
|
|
|
|
|
this.store.set({ openShareDialog: true })
|
|
|
|
this.store.clearComposeData('dialog')
|
|
|
|
this.store.setComposeData('dialog', { text })
|
|
|
|
this.store.save()
|
|
|
|
|
|
|
|
goto('/', { replaceState: true })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|