diff --git a/bin/build-vercel-json.js b/bin/build-vercel-json.js
index 756d927c..fdf1eb8e 100644
--- a/bin/build-vercel-json.js
+++ b/bin/build-vercel-json.js
@@ -79,7 +79,7 @@ const HTML_HEADERS = {
"frame-ancestors 'none'",
"object-src 'none'",
"manifest-src 'self'",
- "form-action 'none'",
+ "form-action 'self'", // we need form-action for the Web Share Target API
"base-uri 'self'"
].join(';'),
'referrer-policy': 'no-referrer',
diff --git a/src/routes/_actions/showShareDialogIfNecessary.js b/src/routes/_actions/showShareDialogIfNecessary.js
index dcf0f231..f86aeed5 100644
--- a/src/routes/_actions/showShareDialogIfNecessary.js
+++ b/src/routes/_actions/showShareDialogIfNecessary.js
@@ -1,11 +1,37 @@
import { store } from '../_store/store'
-import { importShowComposeDialog } from '../_components/dialog/asyncDialogs/importShowComposeDialog.js'
+import { importShowComposeDialog } from '../_components/dialog/asyncDialogs/importShowComposeDialog'
+import { database } from '../_database/database'
+import { doMediaUpload } from './media'
export async function showShareDialogIfNecessary () {
- const { isUserLoggedIn, openShareDialog } = store.get()
- store.set({ openShareDialog: false })
- if (isUserLoggedIn && openShareDialog) {
- const showComposeDialog = await importShowComposeDialog()
- showComposeDialog()
+ const { isUserLoggedIn } = store.get()
+ if (!isUserLoggedIn) {
+ return
+ }
+ const data = await database.getWebShareData()
+ if (!data) {
+ return
+ }
+
+ // delete from IDB and import the dialog in parallel
+ const [showComposeDialog] = await Promise.all([
+ importShowComposeDialog(),
+ database.deleteWebShareData()
+ ])
+
+ console.log('share data', data)
+ const { title, text, url, file } = data
+
+ // url is currently ignored on Android, but one can dream
+ // https://web.dev/web-share-target/#verifying-shared-content
+ const composeText = [title, text, url].filter(Boolean).join('\n\n')
+
+ store.clearComposeData('dialog')
+ store.setComposeData('dialog', { text: composeText })
+ store.save()
+
+ showComposeDialog()
+ if (file) { // start the upload once the dialog is in view so it shows the loading spinner and everything
+ /* no await */ doMediaUpload('dialog', file)
}
}
diff --git a/src/routes/_database/databaseApis.js b/src/routes/_database/databaseApis.js
index 6f9bf298..4a39760a 100644
--- a/src/routes/_database/databaseApis.js
+++ b/src/routes/_database/databaseApis.js
@@ -9,3 +9,4 @@ export * from './timelines/deletion'
export { insertTimelineItems, insertStatus } from './timelines/insertion'
export * from './meta'
export * from './relationships'
+export * from './webShare'
diff --git a/src/routes/_database/webShare.js b/src/routes/_database/webShare.js
new file mode 100644
index 00000000..2d54f130
--- /dev/null
+++ b/src/routes/_database/webShare.js
@@ -0,0 +1,18 @@
+import { get, set, close, del } from '../_thirdparty/idb-keyval/idb-keyval'
+import { WEB_SHARE_TARGET_DATA_IDB_KEY } from '../_static/share'
+
+export function deleteWebShareData () {
+ return del(WEB_SHARE_TARGET_DATA_IDB_KEY)
+}
+
+export function setWebShareData (data) {
+ return set(WEB_SHARE_TARGET_DATA_IDB_KEY, data)
+}
+
+export function getWebShareData () {
+ return get(WEB_SHARE_TARGET_DATA_IDB_KEY)
+}
+
+export function closeKeyValIDBConnection () {
+ return close()
+}
diff --git a/src/routes/_pages/search.html b/src/routes/_pages/search.html
index 9145b390..0edd6f4e 100644
--- a/src/routes/_pages/search.html
+++ b/src/routes/_pages/search.html
@@ -19,7 +19,6 @@
{intl.favorites}
{intl.directMessages}
{intl.bookmarks}
- {intl.shareStatus}
{/if}