From 3b846eb52f7b56db8c461e24341b2f175d0c7452 Mon Sep 17 00:00:00 2001 From: Hiba-Almade Date: Thu, 24 Nov 2022 16:28:25 +0300 Subject: [PATCH 1/3] fix duplicates features when shared. --- widget/app.js | 56 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/widget/app.js b/widget/app.js index 2b8f6d7..d5b136e 100644 --- a/widget/app.js +++ b/widget/app.js @@ -142,7 +142,6 @@ function updateRecordsForSorting() { allItems.map(item => { item.data.titleIndex = item.data.title.toLowerCase(); buildfire.userData.update(item.id, item.data, "topics", (err, res) => { - console.log(res) }) }); } @@ -534,16 +533,16 @@ function getBreadcrumbs() { if (err) reject(err); let homeBreadcrumb = null; breadcrumbs.map(bread => { - if (bread.label === "Home") { + if (bread?.label === "Home") { bread.label = context.title; homeBreadcrumb = bread; pluginBreadCrumbs.push(bread); } - if (bread.options.instanceId === context.instanceId) { + if (bread?.options.instanceId === context.instanceId) { pluginBreadCrumbs.push(bread); } - if (bread.label === context.title) { - if (bread.label !== homeBreadcrumb.label) { + if (bread?.label === context.title) { + if (bread?.label !== homeBreadcrumb?.label) { pluginBreadCrumbs.push(bread); } } @@ -942,50 +941,51 @@ function setStrings() { } function shareWithOthers(data) { - console.log(data) - let link = {}; - link.title = data.title; - link.type = "website"; - link.description = "Join group"; let toShare = {}; - toShare.title = data.title; - toShare.createdBy = { _id: data.createdBy._id }; - toShare.privacy = data.privacy; - toShare.type = data.type; - console.log(toShare); - link.data = { - toShare + toShare.data = { + id: data.id, + title: data.title, + privacy: data.privacy, + createdById: data.createdBy._id, + parentTopicId: data.parentTopicId, + type: data.type, }; - - buildfire.deeplink.generateUrl(link, function (err, result) { + buildfire.deeplink.generateUrl(toShare, function (err, result) { if (err) { console.error(err) } else { buildfire.device.share({ - subject: link.title, - text: link.description, - image: 'http://myImageUrl', + subject: data.title, + text: "Join group", link: result.url }, function (err, result) { if (err) console.log(err) else console.log(result) - Helper.trackAction(Helper.EVENTS.TOPIC_SHEARED); + Helper.trackAction(Helper.EVENTS.TOPIC_SHEARED); }); } }); } function subscribeToGroup(data) { - let group = data.toShare; - if (group.privacy === 'public') return getData(); - if (group.createdBy._id === loggedUser._id) return getData(); + let group = data.data; + if (group?.privacy === 'public') { + getData(); + navigateTo(data); + return; + } + if (group?.createdById === loggedUser._id) { + getData(); + navigateTo(data); + return; + } let searchOptions = {} searchOptions.filter = { $and: [ { '$json.createdBy._id': loggedUser._id }, - { '$json.title': group.title }, + { '$json.title': group?.title }, ] } buildfire.userData.search(searchOptions, 'topics', function (err, result) { @@ -994,6 +994,7 @@ function subscribeToGroup(data) { } if (result && result.length > 0) { getData(); + navigateTo(result) } else { const topic = new Topic({ @@ -1008,6 +1009,7 @@ function subscribeToGroup(data) { .then((result => { showMessage(`You have been added to ${topic.title} topic`) getData(); + navigateTo(result); })) .catch(err => { console.error(err); From b8ecae314cffd0b91dc539f80767b9b5f1e40c88 Mon Sep 17 00:00:00 2001 From: Hiba-Almade Date: Thu, 22 Dec 2022 16:04:57 +0300 Subject: [PATCH 2/3] fix deepLink --- widget/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widget/app.js b/widget/app.js index d5b136e..0d94093 100644 --- a/widget/app.js +++ b/widget/app.js @@ -278,6 +278,7 @@ function loadData(filterData) { ...obj.data, id: obj.id }); + topic.privacy= config.privacy; renderTopic(topic); } @@ -970,7 +971,7 @@ function shareWithOthers(data) { } function subscribeToGroup(data) { - let group = data.data; + let group = data; if (group?.privacy === 'public') { getData(); navigateTo(data); From e49333ff1dc9b0c4c6a434de54e0c0387e5134ed Mon Sep 17 00:00:00 2001 From: Hiba-Almade Date: Wed, 4 Jan 2023 20:55:36 +0300 Subject: [PATCH 3/3] enhance deep link --- widget/app.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/widget/app.js b/widget/app.js index 0d94093..c7f3853 100644 --- a/widget/app.js +++ b/widget/app.js @@ -942,16 +942,17 @@ function setStrings() { } function shareWithOthers(data) { - let toShare = {}; - toShare.data = { - id: data.id, - title: data.title, - privacy: data.privacy, - createdById: data.createdBy._id, - parentTopicId: data.parentTopicId, - type: data.type, - }; - buildfire.deeplink.generateUrl(toShare, function (err, result) { + buildfire.deeplink.generateUrl( + { + data:{ + id: data.id, + title: data.title, + privacy: data.privacy, + createdById: data.createdBy._id, + parentTopicId: data.parentTopicId, + type: data.type, + } + }, function (err, result) { if (err) { console.error(err) } else { @@ -972,13 +973,12 @@ function shareWithOthers(data) { function subscribeToGroup(data) { let group = data; + getData(); if (group?.privacy === 'public') { - getData(); navigateTo(data); return; } if (group?.createdById === loggedUser._id) { - getData(); navigateTo(data); return; } @@ -994,7 +994,6 @@ function subscribeToGroup(data) { console.log(err) } if (result && result.length > 0) { - getData(); navigateTo(result) } else { @@ -1009,7 +1008,6 @@ function subscribeToGroup(data) { topic.save(group.privacy) .then((result => { showMessage(`You have been added to ${topic.title} topic`) - getData(); navigateTo(result); })) .catch(err => {