From 89780586ac052c463c0fae973d005a0f2f1bbe7a Mon Sep 17 00:00:00 2001 From: suppermancool Date: Fri, 3 May 2019 23:56:34 +0700 Subject: [PATCH 1/6] code 30090056 code 30090056 --- src/actions/challenge-listing.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/actions/challenge-listing.js b/src/actions/challenge-listing.js index ad872794..6011c2c9 100644 --- a/src/actions/challenge-listing.js +++ b/src/actions/challenge-listing.js @@ -191,10 +191,9 @@ function getActiveChallengesDone( user = decodeToken(tokenV3).handle; // Handle any errors on this endpoint so that the non-user specific challenges // will still be loaded. - calls.push(service.getUserChallenges(user, filter, { - limit: PAGE_SIZE, - offset: page * PAGE_SIZE, - }).catch(() => ({ challenges: [] }))); + calls.push(getAll( + params => service.getUserChallenges(user, filter, params).catch(() => ({ challenges: [] })), + )); } return Promise.all(calls).then(([ch, uch]) => { /* uch array contains challenges where the user is participating in From e95c91b693a7e1b90e6cba62bcfc56d8ad34930a Mon Sep 17 00:00:00 2001 From: suppermancool Date: Sat, 4 May 2019 00:00:24 +0700 Subject: [PATCH 2/6] update nap shot update nap shot --- __tests__/__snapshots__/index.js.snap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index e7ee51bc..0386661f 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -426,14 +426,17 @@ Object { "countReset": [Function], "debug": [Function], "dir": [Function], + "dirxml": [Function], "error": [Function], "group": [Function], "groupCollapsed": [Function], "groupEnd": [Function], "info": [Function], "log": [Function], + "table": [Function], "time": [Function], "timeEnd": [Function], + "timeLog": [Function], "trace": [Function], "warn": [Function], }, From c5828ccd2758438578783bd5d8b7eeee4fb1cc7b Mon Sep 17 00:00:00 2001 From: suppermancool Date: Sat, 4 May 2019 09:47:41 +0700 Subject: [PATCH 3/6] code 30090056 code 30090056 --- src/actions/challenge-listing.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/actions/challenge-listing.js b/src/actions/challenge-listing.js index 6011c2c9..2e9c0d08 100644 --- a/src/actions/challenge-listing.js +++ b/src/actions/challenge-listing.js @@ -191,31 +191,33 @@ function getActiveChallengesDone( user = decodeToken(tokenV3).handle; // Handle any errors on this endpoint so that the non-user specific challenges // will still be loaded. - calls.push(getAll( - params => service.getUserChallenges(user, filter, params).catch(() => ({ challenges: [] })), - )); + calls.push(service.getUserChallenges(user, filter, { + limit: PAGE_SIZE, + offset: page * PAGE_SIZE, + }).catch(() => ({ challenges: [] }))); } return Promise.all(calls).then(([ch, uch]) => { + let fullCH = ch; /* uch array contains challenges where the user is participating in * some role. The same challenge are already listed in res array, but they * are not attributed to the user there. This block of code marks user * challenges in an efficient way. */ if (uch) { const map = {}; - uch.challenges.forEach((item) => { map[item.id] = item; }); - ch.challenges.forEach((item) => { - if (map[item.id]) { - /* It is fine to reassing, as the array we modifying is created just - * above within the same function. */ - /* eslint-disable no-param-reassign */ - item.users[user] = true; - item.userDetails = map[item.id].userDetails; - /* eslint-enable no-param-reassign */ - } + uch.challenges.forEach((item) => { + map[item.id] = item; + /* eslint-disable no-param-reassign */ + item.users[user] = true; + item.userDetails = map[item.id].userDetails; + /* eslint-enable no-param-reassign */ }); } - let { challenges, meta } = ch; + if (uch) { + fullCH = uch; + } + let { challenges } = fullCH; + let { meta } = ch; // filter by date range and re-compute meta // we can safely remove the next two lines when backend support date range challenges = filterUtil.filterByDate(challenges, frontFilter); From b382b4a071c9d1513135630cedfb8eb34408d282 Mon Sep 17 00:00:00 2001 From: Vigneshkumar Chinnachamy M Date: Thu, 9 May 2019 00:29:09 +0530 Subject: [PATCH 4/6] update email preferences to use v5 api --- .../actions/__snapshots__/profile.js.snap | 1 + .../reducers/__snapshots__/profile.js.snap | 12 ++++---- __tests__/reducers/profile.js | 2 +- config/test.js | 1 + src/actions/profile.js | 2 +- src/reducers/profile.js | 4 +-- src/services/user.js | 28 +++++++++---------- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/__tests__/actions/__snapshots__/profile.js.snap b/__tests__/actions/__snapshots__/profile.js.snap index b784f238..7cfcbef7 100644 --- a/__tests__/actions/__snapshots__/profile.js.snap +++ b/__tests__/actions/__snapshots__/profile.js.snap @@ -166,6 +166,7 @@ Object { }, }, "handle": "tcscoder", + "preferences": Object {}, }, "type": "PROFILE/SAVE_EMAIL_PREFERENCES_DONE", } diff --git a/__tests__/reducers/__snapshots__/profile.js.snap b/__tests__/reducers/__snapshots__/profile.js.snap index a76358ad..da9208ec 100644 --- a/__tests__/reducers/__snapshots__/profile.js.snap +++ b/__tests__/reducers/__snapshots__/profile.js.snap @@ -740,7 +740,7 @@ Object { "deletingPhoto": false, "deletingWebLink": false, "emailPreferences": Object { - "TOPCODER_NL_DATA": true, + "Dev Newsletter": true, }, "externalLinks": Array [ Object { @@ -939,7 +939,7 @@ Object { "deletingPhoto": false, "deletingWebLink": false, "emailPreferences": Object { - "TOPCODER_NL_DATA": true, + "Dev Newsletter": true, }, "externalLinks": Array [ Object { @@ -989,7 +989,7 @@ Object { "deletingPhoto": false, "deletingWebLink": false, "emailPreferences": Object { - "TOPCODER_NL_DATA": true, + "Dev Newsletter": true, }, "externalLinks": Array [ Object { @@ -1926,7 +1926,7 @@ Object { "deletingPhoto": false, "deletingWebLink": false, "emailPreferences": Object { - "TOPCODER_NL_DATA": true, + "Dev Newsletter": true, }, "externalLinks": Array [ Object { @@ -2125,7 +2125,7 @@ Object { "deletingPhoto": false, "deletingWebLink": false, "emailPreferences": Object { - "TOPCODER_NL_DATA": true, + "Dev Newsletter": true, }, "externalLinks": Array [ Object { @@ -2175,7 +2175,7 @@ Object { "deletingPhoto": false, "deletingWebLink": false, "emailPreferences": Object { - "TOPCODER_NL_DATA": true, + "Dev Newsletter": true, }, "externalLinks": Array [ Object { diff --git a/__tests__/reducers/profile.js b/__tests__/reducers/profile.js index 0992cf13..3e9c5ea8 100644 --- a/__tests__/reducers/profile.js +++ b/__tests__/reducers/profile.js @@ -33,7 +33,7 @@ const mockActions = { deleteWebLinkInit: mockAction('DELETE_WEB_LINK_INIT'), deleteWebLinkDone: mockAction('DELETE_WEB_LINK_DONE', { handle, data: webLink }), saveEmailPreferencesInit: mockAction('SAVE_EMAIL_PREFERENCES_INIT'), - saveEmailPreferencesDone: mockAction('SAVE_EMAIL_PREFERENCES_DONE', { handle, data: { subscriptions: { TOPCODER_NL_DATA: true } } }), + saveEmailPreferencesDone: mockAction('SAVE_EMAIL_PREFERENCES_DONE', { handle, preferences: { 'Dev Newsletter': true } }), linkExternalAccountInit: mockAction('LINK_EXTERNAL_ACCOUNT_INIT'), linkExternalAccountDone: mockAction('LINK_EXTERNAL_ACCOUNT_DONE', { handle, data: linkedAccount2 }), unlinkExternalAccountInit: mockAction('UNLINK_EXTERNAL_ACCOUNT_INIT'), diff --git a/config/test.js b/config/test.js index 30d81af5..919351db 100644 --- a/config/test.js +++ b/config/test.js @@ -2,6 +2,7 @@ module.exports = { API: { V2: 'https://api.topcoder-dev.com/v2', V3: 'https://api.topcoder-dev.com/v3', + V5: 'https://api.topcoder-dev.com/v5', }, dummyConfigKey: 'Dummy config value', }; diff --git a/src/actions/profile.js b/src/actions/profile.js index 21643c99..dd1a88c0 100644 --- a/src/actions/profile.js +++ b/src/actions/profile.js @@ -397,7 +397,7 @@ function saveEmailPreferencesInit() {} function saveEmailPreferencesDone(profile, tokenV3, preferences) { const service = getUserService(tokenV3); return service.saveEmailPreferences(profile, preferences) - .then(res => ({ data: res, handle: profile.handle })); + .then(res => ({ data: res, handle: profile.handle, preferences })); } /** diff --git a/src/reducers/profile.js b/src/reducers/profile.js index 8ca03fdf..1cfe741e 100644 --- a/src/reducers/profile.js +++ b/src/reducers/profile.js @@ -434,13 +434,13 @@ function onSaveEmailPreferencesDone(state, { payload, error }) { return newState; } - if (newState.profileForHandle !== payload.handle || !payload.data) { + if (newState.profileForHandle !== payload.handle) { return newState; } return { ...newState, - emailPreferences: payload.data.subscriptions, + emailPreferences: payload.preferences, }; } diff --git a/src/services/user.js b/src/services/user.js index 802f5af3..2fa7c0f6 100644 --- a/src/services/user.js +++ b/src/services/user.js @@ -114,6 +114,7 @@ class User { this.private = { api: getApi('V3', tokenV3), apiV2: getApi('V2', tokenV2), + apiV5: getApi('V5', tokenV3), tokenV2, tokenV3, }; @@ -174,10 +175,10 @@ class User { * @returns {Promise} Resolves to the email preferences result */ async getEmailPreferences(userId) { - const url = `/users/${userId}/preferences/email`; - const res = await this.private.api.get(url); - const x = (await res.json()).result; - return x.content; + const url = `/users/${userId}/preferences`; + const res = await this.private.apiV5.get(url); + const x = (await res.json()); + return x.email; } /** @@ -193,18 +194,17 @@ class User { const settings = { firstName, lastName, - subscriptions: {}, + createdBy: String(userId), + updatedBy: String(userId), + subscriptions: preferences, }; - if (!preferences) { - settings.subscriptions.TOPCODER_NL_GEN = true; - } else { - settings.subscriptions = preferences; - } - const url = `/users/${userId}/preferences/email`; - - const res = await this.private.api.putJson(url, { param: settings }); - return getApiResponsePayload(res); + const url = `/users/${userId}/preferences`; + const res = await this.private.apiV5.putJson( + url, + { email: settings, objectId: String(userId) }, + ); + return res; } /** From a78ae4d552ae0cacc910e9f814f2bdb586aa4c6a Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Fri, 10 May 2019 12:24:55 +0300 Subject: [PATCH 5/6] Fix tests --- __tests__/__snapshots__/index.js.snap | 3 --- 1 file changed, 3 deletions(-) diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index 0386661f..e7ee51bc 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -426,17 +426,14 @@ Object { "countReset": [Function], "debug": [Function], "dir": [Function], - "dirxml": [Function], "error": [Function], "group": [Function], "groupCollapsed": [Function], "groupEnd": [Function], "info": [Function], "log": [Function], - "table": [Function], "time": [Function], "timeEnd": [Function], - "timeLog": [Function], "trace": [Function], "warn": [Function], }, From dbabfda8dbcab62af5f9de813a4f4fa68d89ab67 Mon Sep 17 00:00:00 2001 From: Sushil Date: Fri, 10 May 2019 16:13:07 +0530 Subject: [PATCH 6/6] bump npm version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8be6639..d0fa7e8c 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .", "test": "npm run lint && npm run jest" }, - "version": "0.7.13", + "version": "0.7.14", "dependencies": { "auth0-js": "^6.8.4", "isomorphic-fetch": "^2.2.1", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy