refactor: update share request flow (#3805)

This commit is contained in:
Nivedin
2024-02-05 23:50:15 +05:30
committed by GitHub
parent 0028f6e878
commit 3911c9cd1f
5 changed files with 66 additions and 16 deletions

View File

@@ -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)