Dead code / type error removal
parent
23601375eb
commit
5f5e188cf9
|
@ -19,7 +19,6 @@ jest.mock("../session", () => {
|
|||
|
||||
import { maybeRefreshToken } from "../refresh_token";
|
||||
import { API } from "../api/index";
|
||||
import { Session } from "../session";
|
||||
|
||||
API.setBaseUrl("http://blah.whatever.party");
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import { withTimeout } from "../util";
|
|||
import { AuthState } from "../auth/interfaces";
|
||||
|
||||
export const storeToken =
|
||||
(old: AuthState, dispatch: Function) => (knew: AuthState | undefined) => {
|
||||
const t = knew || old;
|
||||
if (!knew) {
|
||||
(old: AuthState, dispatch: Function) => (_new: AuthState | undefined) => {
|
||||
const t = _new || old;
|
||||
if (!_new) {
|
||||
console.warn("Failed to refresh token. Something is wrong.");
|
||||
}
|
||||
dispatch(setToken(t));
|
||||
|
@ -29,8 +29,8 @@ export function ready(): Thunk {
|
|||
if (auth) {
|
||||
const ok = storeToken(auth, dispatch);
|
||||
const no = () => ok(undefined);
|
||||
|
||||
withTimeout(MAX_TOKEN_WAIT_TIME, maybeRefreshToken(auth)).then(ok, no);
|
||||
const p = maybeRefreshToken(auth);
|
||||
withTimeout(MAX_TOKEN_WAIT_TIME, p).then(ok, no);
|
||||
} else {
|
||||
Session.clear();
|
||||
}
|
||||
|
|
|
@ -47,16 +47,3 @@ export function fetchSyncData(dispatch: Function) {
|
|||
fetch<Sequence[]>("sequences", API.current.sequencesPath);
|
||||
fetch<Tool[]>("tools", API.current.toolsPath);
|
||||
}
|
||||
|
||||
export function fetchSyncDataOk(payload: {}) {
|
||||
return {
|
||||
type: "FETCH_SYNC_OK", payload
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchSyncDataNo(err: Error) {
|
||||
return {
|
||||
type: "FETCH_SYNC_NO",
|
||||
payload: {}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -461,5 +461,5 @@ export function withTimeout<T>(ms: number, promise: Promise<T>) {
|
|||
});
|
||||
|
||||
// Returns a race between our timeout and the passed in promise
|
||||
return Promise.race([promise, timeout]);
|
||||
return Promise.race([promise, timeout]) as Promise<T>;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue