Skip to content

Commit

Permalink
testing old ShareApi code
Browse files Browse the repository at this point in the history
  • Loading branch information
bonomite committed Apr 14, 2023
1 parent 8fad2f2 commit 6bb03f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions components/EpisodeHead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const copyTranscriptLink = () => {
text: props.episode['tease'],
url: `${props.episode['url']}transcript`,
},
'Episode link copied to the clipboard',
true
'Episode link copied to the clipboard'
//true
)
$analytics.sendEvent('click_tracking', {
event_category: 'Click Tracking',
Expand Down
8 changes: 6 additions & 2 deletions components/EpisodeTools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ const shareItems = ref([
label: 'Copy link',
icon: 'pi pi-link',
command: () => {
console.log(
'link =',
`${props.episode['url']}${props.isTranscript ? 'transcript' : ''}`
)
shareAPI(
{
title: props.episode['title'],
Expand All @@ -116,8 +120,8 @@ const shareItems = ref([
props.isTranscript ? 'transcript' : ''
}`,
},
'Episode link copied to the clipboard',
true
'Episode link copied to the clipboard'
//true
)
$analytics.sendEvent('click_tracking', {
event_category: 'Click Tracking',
Expand Down
23 changes: 15 additions & 8 deletions utilities/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,22 @@ export const decodeHTMLEntities = (str) => {

// global funcrtion for shareApi and copyToClipboard fallback
// fyi, This feature is available only in secure contexts (HTTPS), etc... testing local will have no result on mobile, using browserstack works for andriod-chrome only... Best to just test it on the DEMO link.
export const shareAPI = async (content, msg, isLinkOnly = false) => {
//convert html entities to plain text
if (!isLinkOnly) {
if (content.text) { content.text = decodeHTMLEntities(content.text) }
if (content.title) { content.title = decodeHTMLEntities(content.title) }
}
//check if the share api is available and if the browser is mobile
// export const shareAPI = async (content, msg, isLinkOnly = false) => {
// //convert html entities to plain text
// if (!isLinkOnly) {
// if (content.text) { content.text = decodeHTMLEntities(content.text) }
// if (content.title) { content.title = decodeHTMLEntities(content.title) }
// }
// //check if the share api is available and if the browser is mobile
// if (navigator.canShare && isMobileBrowser()) {
// await navigator.share(isLinkOnly ? content.url : content)
// } else {
// copyToClipBoard(content.url, msg)
// }
// }
export const shareAPI = async (content, msg) => {
if (navigator.canShare && isMobileBrowser()) {
await navigator.share(isLinkOnly ? content.url : content)
await navigator.share(content)
} else {
copyToClipBoard(content.url, msg)
}
Expand Down

0 comments on commit 6bb03f4

Please sign in to comment.