ptn-helpers 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +10 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var FEED_LINK_KEYS = [
|
|
|
8
8
|
"_ptr_open_graph_type",
|
|
9
9
|
];
|
|
10
10
|
var itemToNode = function (feedItem, hashtag) {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
12
12
|
var children = [];
|
|
13
13
|
var text = (_a = feedItem === null || feedItem === void 0 ? void 0 : feedItem.content_text) !== null && _a !== void 0 ? _a : "";
|
|
14
14
|
if (((_c = (_b = feedItem === null || feedItem === void 0 ? void 0 : feedItem.attachments) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 1 && ((_d = feedItem === null || feedItem === void 0 ? void 0 : feedItem.attachments) === null || _d === void 0 ? void 0 : _d[0]._ptr_media_type) === "text") {
|
|
@@ -48,16 +48,23 @@ var itemToNode = function (feedItem, hashtag) {
|
|
|
48
48
|
}
|
|
49
49
|
else if ((attachment_1 === null || attachment_1 === void 0 ? void 0 : attachment_1._ptr_media_type) === "image") {
|
|
50
50
|
text = "");
|
|
51
|
+
// this is captions
|
|
52
|
+
if ((_m = (_l = attachment_1 === null || attachment_1 === void 0 ? void 0 : attachment_1.title) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0 > 0) {
|
|
53
|
+
children.push({
|
|
54
|
+
text: "".concat(attachment_1.title),
|
|
55
|
+
children: [],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
51
58
|
}
|
|
52
59
|
else if ((attachment_1 === null || attachment_1 === void 0 ? void 0 : attachment_1._ptr_media_type) === "audio") {
|
|
53
|
-
var title = ((
|
|
60
|
+
var title = ((_p = (_o = feedItem.content_text) === null || _o === void 0 ? void 0 : _o.trim()) === null || _p === void 0 ? void 0 : _p.length) > 0 ? feedItem.content_text : "Audio Recording";
|
|
54
61
|
text = "[".concat(title, "](").concat(attachment_1.url, ")");
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
text = "".concat(text.trim());
|
|
58
65
|
var validHashtag = hashtag && typeof hashtag === "string" && hashtag.length > 0;
|
|
59
66
|
var existingTags = /#\w+to(roam|note)/;
|
|
60
|
-
var needsNewTag = !!!((
|
|
67
|
+
var needsNewTag = !!!((_q = text.match(existingTags)) === null || _q === void 0 ? void 0 : _q.length);
|
|
61
68
|
if (validHashtag && needsNewTag) {
|
|
62
69
|
text = "".concat(text, " #").concat(hashtag);
|
|
63
70
|
}
|