Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
don't set the loading state to false if forceFetch is true
Browse files Browse the repository at this point in the history
  • Loading branch information
James Baxley committed May 28, 2016
1 parent 69921f6 commit a49c965
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,29 @@ export default function connect(opts?: ConnectOptions) {
continue;
}

const { query, variables } = queryHandles[key];
const { query, variables, forceFetch } = queryHandles[key];

const handle = watchQuery(queryHandles[key]);

// rudimentary way to manually check cache
let queryData = defaultQueryData as any;
try {
const result = readQueryFromStore({
store: store.getState()[reduxRootKey].data,
query,
variables,
});

queryData = assign({
errors: null,
loading: false,
}, result);
} catch (e) {/* tslint */}

// force fetch shouldn't try to read from the store
if (!forceFetch) {
try {
const result = readQueryFromStore({
store: store.getState()[reduxRootKey].data,
query,
variables,
});

queryData = assign({
errors: null,
loading: false,
}, result);
} catch (e) {/* tslint */}

}

this.data[key] = queryData;

Expand Down

0 comments on commit a49c965

Please sign in to comment.