@times-components/article-comments 0.30.4 → 0.30.5
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/CHANGELOG.md +11 -0
- package/dist/comment-login.js +2 -2
- package/dist/comments.js +15 -6
- package/dist/utils.js +5 -10
- package/package.json +2 -2
- package/rnw.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.30.5](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.30.4...@times-components/article-comments@0.30.5) (2022-09-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **TDP-2475:** Add event listener to real name commenting reauthentication ([#3140](https://github.com/newsuk/times-components/issues/3140)) ([655b90d](https://github.com/newsuk/times-components/commit/655b90da4eff2afe0f4526b9ec26ce43fb92b747))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.30.4](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.30.3...@times-components/article-comments@0.30.4) (2022-09-07)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @times-components/article-comments
|
package/dist/comment-login.js
CHANGED
|
@@ -34,9 +34,9 @@ const executeSSOtransaction = callback => {
|
|
|
34
34
|
if (window.SPOTIM && window.SPOTIM.startSSO) {
|
|
35
35
|
window.SPOTIM.startSSO(ssoCallback);
|
|
36
36
|
callback();
|
|
37
|
-
const
|
|
37
|
+
const isRealNameReauthenticationEnabled = window.location.search.includes("enableRealNameReauthentication");
|
|
38
38
|
|
|
39
|
-
if (
|
|
39
|
+
if (isRealNameReauthenticationEnabled) {
|
|
40
40
|
setNewUserToken();
|
|
41
41
|
}
|
|
42
42
|
}
|
package/dist/comments.js
CHANGED
|
@@ -112,12 +112,13 @@ class Comments extends _react.Component {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
const
|
|
115
|
+
const isRealNameCommentingEnabled = window.location.search.includes("enableRealNameCommenting");
|
|
116
|
+
const isRealNameReauthenticationEnabled = window.location.search.includes("enableRealNameReauthentication");
|
|
116
117
|
document.addEventListener("spot-im-current-user-typing-start", /*#__PURE__*/function () {
|
|
117
118
|
var _ref = _asyncToGenerator(function* (event) {
|
|
118
119
|
onCommentStart(event);
|
|
119
120
|
|
|
120
|
-
if (
|
|
121
|
+
if (isRealNameCommentingEnabled) {
|
|
121
122
|
const displayName = (0, _utils.getDisplayNameFromLocalStorage)();
|
|
122
123
|
if (!displayName) return;
|
|
123
124
|
const shouldShowBanner = yield (0, _utils.userShouldUpdateName)(displayName);
|
|
@@ -143,16 +144,24 @@ class Comments extends _react.Component {
|
|
|
143
144
|
document.addEventListener("spot-im-user-notifications-click", onCommentNotificationClicked);
|
|
144
145
|
document.addEventListener("spot-im-open-user-profile", onCommentUsernameClicked);
|
|
145
146
|
document.addEventListener("spot-im-share-type", event => getShareEvent(event));
|
|
147
|
+
document.addEventListener("spot-im-user-auth-success", () => {
|
|
148
|
+
if (isRealNameReauthenticationEnabled) {
|
|
149
|
+
if (!(0, _utils.hasRealNameCommentingToken)()) {
|
|
150
|
+
window.localStorage.removeItem("SPOTIM_DEVICE_V2");
|
|
151
|
+
window.localStorage.removeItem("SPOTIM_CURRENT_USER");
|
|
152
|
+
window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN");
|
|
153
|
+
window.localStorage.removeItem("SPOT_AB");
|
|
154
|
+
window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2");
|
|
155
|
+
(0, _commentLogin.default)(() => {});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
146
159
|
|
|
147
160
|
if (!isReadOnly) {
|
|
148
161
|
if (window.SPOTIM && window.SPOTIM.startSSO) {
|
|
149
162
|
(0, _commentLogin.default)(() => {});
|
|
150
163
|
} else {
|
|
151
164
|
document.addEventListener("spot-im-api-ready", () => {
|
|
152
|
-
if (isFeatureFlagEnabled) {
|
|
153
|
-
(0, _utils.shouldReauthenticateUser)();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
165
|
(0, _commentLogin.default)(() => {});
|
|
157
166
|
});
|
|
158
167
|
}
|
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.getDisplayNameFromLocalStorage = exports.
|
|
6
|
+
exports.default = exports.getDisplayNameFromLocalStorage = exports.hasRealNameCommentingToken = exports.userShouldUpdateName = void 0;
|
|
7
7
|
|
|
8
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
9
|
|
|
@@ -42,17 +42,12 @@ const userShouldUpdateName = /*#__PURE__*/function () {
|
|
|
42
42
|
|
|
43
43
|
exports.userShouldUpdateName = userShouldUpdateName;
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
window.localStorage.removeItem("SPOTIM_DEVICE_V2");
|
|
49
|
-
window.localStorage.removeItem("SPOTIM_CURRENT_USER");
|
|
50
|
-
window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN");
|
|
51
|
-
window.localStorage.removeItem("SPOT_AB");
|
|
52
|
-
window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2");
|
|
45
|
+
const hasRealNameCommentingToken = () => {
|
|
46
|
+
const getRealNameCommentingToken = window.localStorage.getItem("isUsingRealNameCommenting");
|
|
47
|
+
return getRealNameCommentingToken;
|
|
53
48
|
};
|
|
54
49
|
|
|
55
|
-
exports.
|
|
50
|
+
exports.hasRealNameCommentingToken = hasRealNameCommentingToken;
|
|
56
51
|
|
|
57
52
|
const getDisplayNameFromLocalStorage = () => {
|
|
58
53
|
const spotimUserDetails = window.localStorage.getItem("SPOTIM_CURRENT_USER");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@times-components/article-comments",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.5",
|
|
4
4
|
"description": "Article Comments",
|
|
5
5
|
"main": "dist/article-comments",
|
|
6
6
|
"dev": "src/article-comments",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "768c0d58bb01b55db27bc09c050d5520520db28f"
|
|
72
72
|
}
|
package/rnw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(5),n(2)),a=n.n(r),m=n(4),c=n(3),s=n.n(c),l=n(0);const d=s.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],l.breakpoints.medium,l.breakpoints.wide),u=(s.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",';font-family:"','";font-size:',"px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.primary,l.fonts.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6)),f=(e,t)=>((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const e=(200===n.status?JSON.parse(n.response):{}).spotimCodeB;e&&t(e)}),n.open("GET",e),n.send()})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t);var g=e=>{if(window.SPOTIM&&window.SPOTIM.startSSO){window.SPOTIM.startSSO(f),e();window.location.search.includes("enableRealNameCommenting")&&window.localStorage.setItem("isUsingRealNameCommenting",!0)}},C=n(6);function b(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}const v={gb:"https://thetimes.co.uk/subscribe/digital?ILC=GB-TNL_The_Times-Conversion_Page-Homepage-2020",ie:"https://store.thetimes.ie/?ILC=IE-TNL_The_Times-Conversion_Page-Homepage-2020",global:"https://globalstore.thetimes.co.uk/?ILC=INTL-TNL_The_Times-Conversion_Page-Homepage-2020"},h=function(){var e,t=(e=function*(e){if(!e)return!1;const t="/api/comments/display-names-pseudonyms?username=".concat(e),n=fetch(t).then(e=>e.json()).then(e=>e),o=(yield n).isPseudonym;return o||!1},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){b(r,o,i,a,m,"next",e)}function m(e){b(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}();function w(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}class y extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.publishedTime,i=e.commentingConfig,r=e.onCommentStart,a=e.onCommentPost,m=e.onCommentNotification,c=e.onCommentFilterNewest,s=e.onCommentFilterMostRecommended,l=e.onCommentFilterOldest,d=e.onCommentReplyClick,u=e.onCommentShareLink,p=e.onCommentShareTwitter,f=e.onCommentShareEmail,C=e.onCommentShareFacebook,b=e.onCommentRecommend,v=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,O=e.onCommentSettingsClicked;if(!this.container||!t||!i)return;let k=i.account.readOnly;if(i&&i.switchOver){o>i.switchOver&&(k=i.account.current)}const N=window.location.search.includes("enableRealNameCommenting");document.addEventListener("spot-im-current-user-typing-start",function(){var e,t=(e=function*(e){if(r(e),N){const e=(()=>{const e=window.localStorage.getItem("SPOTIM_CURRENT_USER");return e&&(e&&JSON.parse(e)).data.displayName||!1})();if(!e)return;(yield h(e))&&window.dispatchEvent(new CustomEvent("SHOW_REAL_NAME_COMMENTING_BANNER",{}))}},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){w(r,o,i,a,m,"next",e)}function m(e){w(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),{once:!0}),document.addEventListener("spot-im-current-user-sent-message",a),document.addEventListener("spot-im-notification-drop-down-link",m),document.addEventListener("spot-im-user-up-vote-click",b),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return s(e);case"oldest":return l(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",d),document.addEventListener("spot-im-clicked-settings",O),document.addEventListener("spot-im-user-notifications-click",v),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return u(e);case"email":return f(e);case"twitter":return p(e);case"facebook":return C(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?g(()=>{}):document.addEventListener("spot-im-api-ready",()=>{N&&(window.localStorage.getItem("isUsingRealNameCommenting")||(window.localStorage.removeItem("SPOTIM_DEVICE_V2"),window.localStorage.removeItem("SPOTIM_CURRENT_USER"),window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN"),window.localStorage.removeItem("SPOT_AB"),window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2"))),g(()=>{})}));const S=document.createElement("script");S.setAttribute("async","async"),S.setAttribute("src","https://launcher.spot.im/spot/".concat(k)),S.setAttribute("data-spotim-module","spotim-launcher"),S.setAttribute("data-post-id",t),S.setAttribute("data-post-url","https://www.thetimes.co.uk/article/".concat(t)),S.setAttribute("data-seo-enabled",!0),S.setAttribute("data-livefyre-url",t),this.container.appendChild(S)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,l=e.onCommentShareTwitter,u=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(d,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:u,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}y.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var O,k=(O=y,Object(C.withTrackEvents)(O,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]})),N=n(7);function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:E(E({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:E(E({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var R=_(_({},P),{},{link:_(_({},P.link),{},{fontFamily:l.fonts.supporting,fontSize:l.fontSizes.commentsGuidelines})});var x=()=>i.a.createElement(d,null,i.a.createElement(p,null,"Comments for this article have been turned off"),i.a.createElement(u,null,"Comments are subject to our community guidelines, which can be viewed"," ",i.a.createElement(N.TextLink,{style:R.link,url:"https://www.thetimes.co.uk/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),"."));function L(){const e=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,t=e?null:(()=>{const e="undefined"!=typeof window&&window.nuk&&window.nuk.region;return v[e]||v.gb})(),n=e?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(m.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:t,onClick:n},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")}const M=e=>{let t=e.articleId,n=e.publishedTime,o=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig;return o?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.metered},i.a.createElement(L,null)),i.a.createElement(a.a,{state:a.a.subscriber},i.a.createElement(d,null,i.a.createElement(m.HiddenDiv,{className:"comment-banner"})),i.a.createElement(k,{articleId:t,publishedTime:n,isReadOnly:r,commentingConfig:c}))):i.a.createElement(x,null)};M.defaultProps={isReadOnly:!1};t.default=M}]);
|
|
1
|
+
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(5),n(2)),a=n.n(r),m=n(4),c=n(3),s=n.n(c),l=n(0);const d=s.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],l.breakpoints.medium,l.breakpoints.wide),u=(s.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",';font-family:"','";font-size:',"px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",';font-family:"','";font-size:',"px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],l.colours.functional.primary,l.fonts.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6)),f=(e,t)=>((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const e=(200===n.status?JSON.parse(n.response):{}).spotimCodeB;e&&t(e)}),n.open("GET",e),n.send()})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t);var g=e=>{if(window.SPOTIM&&window.SPOTIM.startSSO){window.SPOTIM.startSSO(f),e();window.location.search.includes("enableRealNameReauthentication")&&window.localStorage.setItem("isUsingRealNameCommenting",!0)}},C=n(6);function b(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}const h={gb:"https://thetimes.co.uk/subscribe/digital?ILC=GB-TNL_The_Times-Conversion_Page-Homepage-2020",ie:"https://store.thetimes.ie/?ILC=IE-TNL_The_Times-Conversion_Page-Homepage-2020",global:"https://globalstore.thetimes.co.uk/?ILC=INTL-TNL_The_Times-Conversion_Page-Homepage-2020"},v=function(){var e,t=(e=function*(e){if(!e)return!1;const t="/api/comments/display-names-pseudonyms?username=".concat(e),n=fetch(t).then(e=>e.json()).then(e=>e),o=(yield n).isPseudonym;return o||!1},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){b(r,o,i,a,m,"next",e)}function m(e){b(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}();function w(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}class y extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.publishedTime,i=e.commentingConfig,r=e.onCommentStart,a=e.onCommentPost,m=e.onCommentNotification,c=e.onCommentFilterNewest,s=e.onCommentFilterMostRecommended,l=e.onCommentFilterOldest,d=e.onCommentReplyClick,u=e.onCommentShareLink,p=e.onCommentShareTwitter,f=e.onCommentShareEmail,C=e.onCommentShareFacebook,b=e.onCommentRecommend,h=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,O=e.onCommentSettingsClicked;if(!this.container||!t||!i)return;let k=i.account.readOnly;if(i&&i.switchOver){o>i.switchOver&&(k=i.account.current)}const N=window.location.search.includes("enableRealNameCommenting"),S=window.location.search.includes("enableRealNameReauthentication");document.addEventListener("spot-im-current-user-typing-start",function(){var e,t=(e=function*(e){if(r(e),N){const e=(()=>{const e=window.localStorage.getItem("SPOTIM_CURRENT_USER");return e&&(e&&JSON.parse(e)).data.displayName||!1})();if(!e)return;(yield v(e))&&window.dispatchEvent(new CustomEvent("SHOW_REAL_NAME_COMMENTING_BANNER",{}))}},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){w(r,o,i,a,m,"next",e)}function m(e){w(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),{once:!0}),document.addEventListener("spot-im-current-user-sent-message",a),document.addEventListener("spot-im-notification-drop-down-link",m),document.addEventListener("spot-im-user-up-vote-click",b),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return s(e);case"oldest":return l(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",d),document.addEventListener("spot-im-clicked-settings",O),document.addEventListener("spot-im-user-notifications-click",h),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return u(e);case"email":return f(e);case"twitter":return p(e);case"facebook":return C(e);default:return null}})(e)),document.addEventListener("spot-im-user-auth-success",()=>{S&&(window.localStorage.getItem("isUsingRealNameCommenting")||(window.localStorage.removeItem("SPOTIM_DEVICE_V2"),window.localStorage.removeItem("SPOTIM_CURRENT_USER"),window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN"),window.localStorage.removeItem("SPOT_AB"),window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2"),g(()=>{})))}),n||(window.SPOTIM&&window.SPOTIM.startSSO?g(()=>{}):document.addEventListener("spot-im-api-ready",()=>{g(()=>{})}));const E=document.createElement("script");E.setAttribute("async","async"),E.setAttribute("src","https://launcher.spot.im/spot/".concat(k)),E.setAttribute("data-spotim-module","spotim-launcher"),E.setAttribute("data-post-id",t),E.setAttribute("data-post-url","https://www.thetimes.co.uk/article/".concat(t)),E.setAttribute("data-seo-enabled",!0),E.setAttribute("data-livefyre-url",t),this.container.appendChild(E)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,l=e.onCommentShareTwitter,u=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(d,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:u,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}y.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var O,k=(O=y,Object(C.withTrackEvents)(O,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]})),N=n(7);function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:E(E({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:E(E({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var R=_(_({},P),{},{link:_(_({},P.link),{},{fontFamily:l.fonts.supporting,fontSize:l.fontSizes.commentsGuidelines})});var x=()=>i.a.createElement(d,null,i.a.createElement(p,null,"Comments for this article have been turned off"),i.a.createElement(u,null,"Comments are subject to our community guidelines, which can be viewed"," ",i.a.createElement(N.TextLink,{style:R.link,url:"https://www.thetimes.co.uk/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),"."));function L(){const e=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,t=e?null:(()=>{const e="undefined"!=typeof window&&window.nuk&&window.nuk.region;return h[e]||h.gb})(),n=e?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(m.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:t,onClick:n},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")}const M=e=>{let t=e.articleId,n=e.publishedTime,o=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig;return o?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.metered},i.a.createElement(L,null)),i.a.createElement(a.a,{state:a.a.subscriber},i.a.createElement(d,null,i.a.createElement(m.HiddenDiv,{className:"comment-banner"})),i.a.createElement(k,{articleId:t,publishedTime:n,isReadOnly:r,commentingConfig:c}))):i.a.createElement(x,null)};M.defaultProps={isReadOnly:!1};t.default=M}]);
|