order sharing
This commit is contained in:
@@ -8,6 +8,12 @@
|
||||
</v-btn>
|
||||
<v-btn variant="text" prepend-icon="mdi-delete" v-if="co.orders.length>0"
|
||||
:disabled="!orderChanged" @click="resetOrder">Reset</v-btn>
|
||||
<v-btn id="share-btn" variant="text" prepend-icon="mdi-share" v-if="co.orders.length>0"
|
||||
:disabled="sharing"
|
||||
@click="shareOrder">{{sharing?'Preparing...':'Share'}}</v-btn>
|
||||
<v-tooltip activator="#share-btn" text="Copied share link!" v-model="showSharedTooltip"
|
||||
:open-on-hover="false" :open-on-click="false"
|
||||
/>
|
||||
</template>
|
||||
<div class="overflow-y-auto">
|
||||
<needs-chart>
|
||||
@@ -66,6 +72,7 @@ import NeedsChart from "@/components/NeedsChart.vue";
|
||||
import {PlaceOrderTransaction} from "@/blockchain/transaction.js";
|
||||
import {errorSuggestsMissingVault} from "@/misc.js";
|
||||
import {track} from "@/track.js";
|
||||
import {getShareUrl} from "@/share.js";
|
||||
|
||||
const s = useStore()
|
||||
const co = useChartOrderStore()
|
||||
@@ -196,6 +203,34 @@ async function doPlaceOrder() {
|
||||
}
|
||||
}
|
||||
|
||||
const sharing = ref(false)
|
||||
const showSharedTooltip = ref(false)
|
||||
const showShareDialog = ref(false)
|
||||
const shareUrl = ref(null)
|
||||
|
||||
function shareOrder() {
|
||||
sharing.value = true
|
||||
getShareUrl().then(url => {
|
||||
shareUrl.value = url
|
||||
sharing.value = false
|
||||
navigator.permissions.query({name: "clipboard-write"}).then((permission) => {
|
||||
const permitted = permission.state === "granted" || permission.state === "prompt"
|
||||
if (!permitted) {
|
||||
showShareDialog.value = true
|
||||
} else {
|
||||
navigator.clipboard.writeText(url)
|
||||
.then(() => {
|
||||
showSharedTooltip.value = true
|
||||
setTimeout(() => showSharedTooltip.value = false, 3000)
|
||||
})
|
||||
.catch(() => {
|
||||
showShareDialog.value = true
|
||||
})
|
||||
}
|
||||
}).catch(() => null)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss"> // NOT scoped
|
||||
|
||||
Reference in New Issue
Block a user