Skip to content

Commit

Permalink
Merge pull request #32 from Financial-Times/revert-31-dont-cache-uuid
Browse files Browse the repository at this point in the history
Revert "Don't cache uuid"
  • Loading branch information
ironsidevsquincy authored Mar 21, 2017
2 parents cb455c6 + 798ecb2 commit 5ac7d66
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const getSessionId = () => {
};

const getUuid = () => {
const cachedUUID = cache('uuid');
if (cachedUUID) {
return Promise.resolve({ uuid: cachedUUID });
}

const sessionId = getSessionId();
if (!sessionId) {
return Promise.resolve({ uuid: undefined });
Expand All @@ -23,6 +28,9 @@ const getUuid = () => {
requests.uuid = request(`/sessions/s/${sessionId}`)
.then(({ uuid } = {}) => {
delete requests.uuid;
if (uuid) {
cache('uuid', uuid);
}
return { uuid };
});
}
Expand Down

0 comments on commit 5ac7d66

Please sign in to comment.