send auth token with status call

This commit is contained in:
jessop 2020-10-27 21:29:45 -04:00 committed by Sean Yesmunt
parent 4d9731d9c2
commit 73c146b9ac
2 changed files with 14 additions and 5 deletions

View file

@ -1329,7 +1329,6 @@
"Replying as": "Replying as",
"No uploads": "No uploads",
"uploads": "uploads",
"Community": "Community",
"Staked LBRY Credits": "Staked LBRY Credits",
"1 comment": "1 comment",
"%total_comments% comments": "%total_comments% comments",
@ -1349,8 +1348,6 @@
"Credit Details": "Credit Details",
"LBRY Credits": "LBRY Credits",
"Mark all as read": "Mark all as read",
"Log in to %SITE_NAME% to earn rewards From Inviting Your Friends": "Log in to %SITE_NAME% to earn rewards From Inviting Your Friends",
"Confirming...": "Confirming...",
"Pinned by @%channel%": "Pinned by @%channel%",
"Pinned by creator": "Pinned by creator",
"Claim Your %reward_amount% Credit Invite Reward": "Claim Your %reward_amount% Credit Invite Reward",
@ -1383,7 +1380,6 @@
"Email Verified": "Email Verified",
"Inviter Bonus": "Inviter Bonus",
"Daily Watch Reward": "Daily Watch Reward",
"Mark all as read": "Mark all as read",
"Odyseenaut": "Odyseenaut",
"Watch 10 things, like 5 things, and leave a comment on odysee.com.": "Watch 10 things, like 5 things, and leave a comment on odysee.com.",
"Earn an upgrade reward with each LBRY update. Patches will not trigger a new reward.": "Earn an upgrade reward with each LBRY update. Patches will not trigger a new reward.",
@ -1460,5 +1456,6 @@
"Unpin": "Unpin",
"LBRY leveled up": "LBRY leveled up",
"This link leads to an external website.": "This link leads to an external website.",
"Hold on, we are setting up your account": "Hold on, we are setting up your account",
"--end--": "--end--"
}

View file

@ -1,5 +1,7 @@
import { SDK_API_PATH } from 'ui';
import { useEffect } from 'react';
import { getAuthToken } from 'util/saved-passwords';
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
import fetchWithTimeout from 'util/fetch';
@ -9,13 +11,23 @@ export const STATUS_DEGRADED = 'degraded';
export const STATUS_FAILING = 'failing';
export const STATUS_DOWN = 'down';
const getParams = () => {
const headers = {};
const token = getAuthToken();
if (token) {
headers[X_LBRY_AUTH_TOKEN] = token;
}
const params = { headers };
return params;
};
export function useDegradedPerformance(onDegradedPerformanceCallback) {
useEffect(() => {
// The status endpoint is the only endpoint at "v2" currently
// This should be moved into the config once more endpoints are using it
const STATUS_ENDPOINT = `${SDK_API_PATH}/status`.replace('v1', 'v2');
fetchWithTimeout(STATUS_TIMEOUT_LIMIT, fetch(STATUS_ENDPOINT))
fetchWithTimeout(STATUS_TIMEOUT_LIMIT, fetch(STATUS_ENDPOINT, getParams()))
.then(response => response.json())
.then(status => {
if (status.general_state !== STATUS_OK) {