mirror of
https://github.com/wassname/talk.git
synced 2026-10-29 13:40:57 +08:00
Introduce separateDataAndRoot
This commit is contained in:
1 parent
df2c33ac35
commit
f142f3a27f
2 files changed
+26
-9
No files matched your search
@@ -6,7 +6,7 @@ import isEqual from 'lodash/isEqual';
|
||||
|
||||
import {Spinner} from 'coral-ui';
|
||||
import {authActions, assetActions, pym} from 'coral-framework';
|
||||
import {getDefinitionName} from 'coral-framework/utils';
|
||||
import {getDefinitionName, separateDataAndRoot} from 'coral-framework/utils';
|
||||
import Embed from '../components/Embed';
|
||||
import {setCommentCountCache, viewAllComments} from '../actions/stream';
|
||||
import {setActiveTab} from '../actions/embed';
|
||||
@@ -84,14 +84,7 @@ export const withQuery = graphql(EMBED_QUERY, {
|
||||
excludeIgnored: Boolean(auth && auth.user && auth.user.id),
|
||||
},
|
||||
}),
|
||||
props: ({data: {
|
||||
fetchMore, loading, networkStatus, refetch, startPolling,
|
||||
stopPolling, subscribeToMore, updateQuery, variables,
|
||||
...root}}) => ({
|
||||
data: {fetchMore, loading, networkStatus, refetch, startPolling,
|
||||
stopPolling, subscribeToMore, updateQuery, variables},
|
||||
root,
|
||||
}),
|
||||
props: ({data}) => separateDataAndRoot(data),
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
|
||||
@@ -37,3 +37,27 @@ export function getDefinitionName(doc, pos = 0) {
|
||||
return doc.definitions[pos].name.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Separate apollo `data` props into `data` and `root`.
|
||||
* `data` will contain props like `loading`, `fetchMore`...
|
||||
* while `root` contains the actual query data.
|
||||
*/
|
||||
export function separateDataAndRoot(
|
||||
{
|
||||
fetchMore,
|
||||
loading,
|
||||
networkStatus,
|
||||
refetch,
|
||||
startPolling,
|
||||
stopPolling,
|
||||
subscribeToMore,
|
||||
updateQuery,
|
||||
variables,
|
||||
...root,
|
||||
}) {
|
||||
return {
|
||||
data: {fetchMore, loading, networkStatus, refetch, startPolling,
|
||||
stopPolling, subscribeToMore, updateQuery, variables},
|
||||
root,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user