Skip to content

Commit

Permalink
Merge pull request #2036 from JoinColony/feature/2005-structured-work…
Browse files Browse the repository at this point in the history
…-aside

Add structured work to colony home aside
  • Loading branch information
ceolson01 authored Feb 20, 2020
2 parents 0c296cc + 897997c commit 1876981
Show file tree
Hide file tree
Showing 11 changed files with 696 additions and 8 deletions.
39 changes: 39 additions & 0 deletions src/data/cacheUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,50 @@ import {
UserQuery,
UserQueryVariables,
UserDocument,
CreateProgramMutationResult,
ColonyProgramsQuery,
ColonyProgramsQueryVariables,
ColonyProgramsDocument,
} from './generated';

type Cache = typeof apolloCache;

const cacheUpdates = {
createProgram(colonyAddress: Address) {
return (cache: Cache, { data }: CreateProgramMutationResult) => {
try {
const cacheData = cache.readQuery<
ColonyProgramsQuery,
ColonyProgramsQueryVariables
>({
query: ColonyProgramsDocument,
variables: {
address: colonyAddress,
},
});
const createProgramData = data && data.createProgram;
if (cacheData && createProgramData) {
const programs = cacheData.colony.programs || [];
programs.push(createProgramData);
cache.writeQuery<ColonyProgramsQuery, ColonyProgramsQueryVariables>({
data: {
colony: {
...cacheData.colony,
programs,
},
},
query: ColonyProgramsDocument,
variables: {
address: colonyAddress,
},
});
}
} catch (e) {
log.verbose(e);
log.verbose('Not updating store - colony programs not loaded yet');
}
};
},
createTask(colonyAddress: Address) {
return (cache: Cache, { data }: CreateTaskMutationResult) => {
try {
Expand Down
Loading

0 comments on commit 1876981

Please sign in to comment.