Dead code / type error removal

pull/502/head
Rick Carlino 2017-10-16 07:36:36 -05:00
parent 23601375eb
commit 5f5e188cf9
4 changed files with 6 additions and 20 deletions

View File

@ -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");

View File

@ -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();
}

View File

@ -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: {}
};
}

View File

@ -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>;
}