Pinafore-Web-Client-Frontend/src/routes/share.html

30 lines
955 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/importLoggedInStoreExtensions.js'
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>