refactor: update share request flow (#3805)
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
@close-tab="removeTab(tab.id)"
|
||||
@close-other-tabs="closeOtherTabsAction(tab.id)"
|
||||
@duplicate-tab="duplicateTab(tab.id)"
|
||||
@share-tab-request="shareTabRequest(tab.id)"
|
||||
/>
|
||||
</template>
|
||||
<template #suffix>
|
||||
@@ -145,6 +146,11 @@ const tabs = useService(RESTTabService)
|
||||
|
||||
const currentTabID = tabs.currentTabID
|
||||
|
||||
const currentUser = useReadonlyStream(
|
||||
platform.auth.getCurrentUserStream(),
|
||||
platform.auth.getCurrentUser()
|
||||
)
|
||||
|
||||
type PopupDetails = {
|
||||
show: boolean
|
||||
position: {
|
||||
@@ -308,6 +314,19 @@ const onSaveModalClose = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const shareTabRequest = (tabID: string) => {
|
||||
const tab = tabs.getTabRef(tabID)
|
||||
if (tab.value) {
|
||||
if (currentUser.value) {
|
||||
invokeAction("share.request", {
|
||||
request: tab.value.document.request,
|
||||
})
|
||||
} else {
|
||||
invokeAction("modals.login.toggle")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const syncTabState = () => {
|
||||
if (tabStateForSync.value)
|
||||
tabs.loadTabsFromPersistedState(tabStateForSync.value)
|
||||
|
||||
Reference in New Issue
Block a user