@financial-times/qanda-ui 0.0.1-beta.46 → 0.0.1-beta.48
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/dist/cjs/index.js
CHANGED
|
@@ -21,9 +21,8 @@ class QandaUI {
|
|
|
21
21
|
throw new Error('Required properties are missing');
|
|
22
22
|
}
|
|
23
23
|
const storyId = options?.storyId ?? containerElement.dataset.qandaStoryid;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
false;
|
|
24
|
+
const stagingData = containerElement.dataset.qandaUsestaging === 'true' ? true : false;
|
|
25
|
+
const useStaging = options?.useStaging ?? stagingData;
|
|
27
26
|
const title = options?.title ?? containerElement.dataset.qandaTitle;
|
|
28
27
|
const commentsAPIHost = options?.commentsAPIHost ?? containerElement.dataset.qandaCommentsapihost;
|
|
29
28
|
const commentsAPIVersion = options?.commentsAPIVersion ??
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.updateComments = void 0;
|
|
5
5
|
const comments_api_1 = require("../services/comments-api");
|
|
6
|
-
const stream_1 = require("
|
|
6
|
+
const stream_1 = require("./stream");
|
|
7
7
|
const qandas_1 = require("../utils/qandas");
|
|
8
8
|
const updateComments = (dispatch, updatedComments, storyId, useStaging, commentsAPIUrl) => {
|
|
9
9
|
if (!updatedComments.length) {
|
|
@@ -15,12 +15,15 @@ const updateComments = (dispatch, updatedComments, storyId, useStaging, comments
|
|
|
15
15
|
dispatch(comments_api_1.nextCommentsApi.util.updateQueryData('getQandAStream',
|
|
16
16
|
// Updates happen only for the live stream, so we pass the status as 'live' hardcoded
|
|
17
17
|
{ storyId, useStaging, commentsAPIUrl, status: 'live' }, (draft) => {
|
|
18
|
-
// NB - if the same comment is updated more than once, the most recent thing added to the array will be the one that is shown
|
|
18
|
+
// NB - if the same comment is updated more than once, the most recent thing added to the array will be the one that is shown, as each update is the full question and answer block
|
|
19
|
+
// this will check if a question already exists in the store, and if so, it will update the object and move to the top of the array so that we don't have duplicates and it is in the right order
|
|
19
20
|
for (let c = 0; c < updatedComments.length; c++) {
|
|
20
21
|
const commentId = updatedComments[c].id;
|
|
21
22
|
const commentIndex = draft.qandas.findIndex((d) => d.id === commentId);
|
|
22
23
|
if (commentIndex > -1) {
|
|
23
24
|
draft.qandas[commentIndex] = updatedComments[c];
|
|
25
|
+
const commentToMove = draft.qandas.splice(commentIndex, 1);
|
|
26
|
+
draft.qandas.unshift(commentToMove[0]);
|
|
24
27
|
}
|
|
25
28
|
else {
|
|
26
29
|
draft.qandas.unshift(updatedComments[c]);
|
package/dist/cjs/utils/auth.js
CHANGED
|
@@ -8,7 +8,9 @@ exports.default = async ({ useStaging = true, displayName = '', commentsAPIUrl =
|
|
|
8
8
|
useStagingEnvironment: useStaging,
|
|
9
9
|
onlySubscribers: true,
|
|
10
10
|
displayName,
|
|
11
|
-
commentsAPIUrl: commentsAPIUrl
|
|
11
|
+
commentsAPIUrl: commentsAPIUrl.startsWith(PROD_AUTH_URL)
|
|
12
|
+
? PROD_AUTH_URL
|
|
13
|
+
: TEST_AUTH_URL,
|
|
12
14
|
});
|
|
13
15
|
// if the JWT creation has failed, a `userHasValidSession` value will be returned
|
|
14
16
|
// our application assumes the values of a JWT are saved to state, so we set the
|
package/dist/esm/index.js
CHANGED
|
@@ -14,9 +14,8 @@ class QandaUI {
|
|
|
14
14
|
throw new Error('Required properties are missing');
|
|
15
15
|
}
|
|
16
16
|
const storyId = options?.storyId ?? containerElement.dataset.qandaStoryid;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
false;
|
|
17
|
+
const stagingData = containerElement.dataset.qandaUsestaging === 'true' ? true : false;
|
|
18
|
+
const useStaging = options?.useStaging ?? stagingData;
|
|
20
19
|
const title = options?.title ?? containerElement.dataset.qandaTitle;
|
|
21
20
|
const commentsAPIHost = options?.commentsAPIHost ?? containerElement.dataset.qandaCommentsapihost;
|
|
22
21
|
const commentsAPIVersion = options?.commentsAPIVersion ??
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// PURPOSE: move the comments saved in updatedComments into the main comments array for the stream and then clear out the updatedComments array, and update the lastAnsweredQuestionId in the store
|
|
2
2
|
import { nextCommentsApi } from '../services/comments-api';
|
|
3
|
-
import { setLatestAnsweredQuestionId } from '
|
|
3
|
+
import { setLatestAnsweredQuestionId } from './stream';
|
|
4
4
|
import { getLatestAnsweredQuestion } from '../utils/qandas';
|
|
5
5
|
export const updateComments = (dispatch, updatedComments, storyId, useStaging, commentsAPIUrl) => {
|
|
6
6
|
if (!updatedComments.length) {
|
|
@@ -12,12 +12,15 @@ export const updateComments = (dispatch, updatedComments, storyId, useStaging, c
|
|
|
12
12
|
dispatch(nextCommentsApi.util.updateQueryData('getQandAStream',
|
|
13
13
|
// Updates happen only for the live stream, so we pass the status as 'live' hardcoded
|
|
14
14
|
{ storyId, useStaging, commentsAPIUrl, status: 'live' }, (draft) => {
|
|
15
|
-
// NB - if the same comment is updated more than once, the most recent thing added to the array will be the one that is shown
|
|
15
|
+
// NB - if the same comment is updated more than once, the most recent thing added to the array will be the one that is shown, as each update is the full question and answer block
|
|
16
|
+
// this will check if a question already exists in the store, and if so, it will update the object and move to the top of the array so that we don't have duplicates and it is in the right order
|
|
16
17
|
for (let c = 0; c < updatedComments.length; c++) {
|
|
17
18
|
const commentId = updatedComments[c].id;
|
|
18
19
|
const commentIndex = draft.qandas.findIndex((d) => d.id === commentId);
|
|
19
20
|
if (commentIndex > -1) {
|
|
20
21
|
draft.qandas[commentIndex] = updatedComments[c];
|
|
22
|
+
const commentToMove = draft.qandas.splice(commentIndex, 1);
|
|
23
|
+
draft.qandas.unshift(commentToMove[0]);
|
|
21
24
|
}
|
|
22
25
|
else {
|
|
23
26
|
draft.qandas.unshift(updatedComments[c]);
|
package/dist/esm/utils/auth.js
CHANGED
|
@@ -6,7 +6,9 @@ export default async ({ useStaging = true, displayName = '', commentsAPIUrl = PR
|
|
|
6
6
|
useStagingEnvironment: useStaging,
|
|
7
7
|
onlySubscribers: true,
|
|
8
8
|
displayName,
|
|
9
|
-
commentsAPIUrl: commentsAPIUrl
|
|
9
|
+
commentsAPIUrl: commentsAPIUrl.startsWith(PROD_AUTH_URL)
|
|
10
|
+
? PROD_AUTH_URL
|
|
11
|
+
: TEST_AUTH_URL,
|
|
10
12
|
});
|
|
11
13
|
// if the JWT creation has failed, a `userHasValidSession` value will be returned
|
|
12
14
|
// our application assumes the values of a JWT are saved to state, so we set the
|