@jobber/hooks 1.11.0 → 1.11.1-pre.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -12
- package/dist/useAssert/index.js +1 -1
- package/dist/useAssert/useAssert.js +1 -0
- package/dist/useCollectionQuery/index.js +1 -1
- package/dist/useCollectionQuery/mdxUtils.d.ts +1 -1
- package/dist/useCollectionQuery/mdxUtils.js +2 -1
- package/dist/useCollectionQuery/test-utilities/index.js +13 -6
- package/dist/useCollectionQuery/test-utilities/mocks.d.ts +34 -59
- package/dist/useCollectionQuery/test-utilities/mocks.js +39 -6
- package/dist/useCollectionQuery/test-utilities/queries.d.ts +2 -1
- package/dist/useCollectionQuery/test-utilities/queries.js +5 -3
- package/dist/useCollectionQuery/test-utilities/utils.js +1 -0
- package/dist/useCollectionQuery/uniqueEdges.js +1 -0
- package/dist/useCollectionQuery/uniqueNodes.js +1 -0
- package/dist/useCollectionQuery/useCollectionQuery.d.ts +1 -1
- package/dist/useCollectionQuery/useCollectionQuery.js +10 -9
- package/dist/useCollectionQuery/useCollectionQuery.test.js +415 -397
- package/dist/useFormState/index.js +1 -1
- package/dist/useFormState/useFormState.d.ts +0 -2
- package/dist/useFormState/useFormState.js +1 -0
- package/dist/useIsMounted/index.js +1 -1
- package/dist/useIsMounted/useIsMounted.js +1 -0
- package/dist/useLiveAnnounce/index.js +1 -1
- package/dist/useLiveAnnounce/useLiveAnnounce.js +1 -0
- package/dist/useOnKeyDown/index.js +1 -1
- package/dist/useOnKeyDown/useOnKeyDown.js +1 -0
- package/dist/usePasswordStrength/index.js +1 -1
- package/dist/usePasswordStrength/usePasswordStrength.js +1 -0
- package/dist/useRefocusOnActivator/index.js +1 -1
- package/dist/useRefocusOnActivator/useRefocusOnActivator.js +1 -0
- package/dist/useResizeObserver/index.js +11 -4
- package/dist/useResizeObserver/useResizeObserver.d.ts +0 -2
- package/dist/useResizeObserver/useResizeObserver.js +1 -0
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
5
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
__exportStar(require("./useAssert"), exports);
|
|
14
|
+
__exportStar(require("./useCollectionQuery"), exports);
|
|
15
|
+
__exportStar(require("./useFormState"), exports);
|
|
16
|
+
__exportStar(require("./useIsMounted"), exports);
|
|
17
|
+
__exportStar(require("./useLiveAnnounce"), exports);
|
|
18
|
+
__exportStar(require("./useOnKeyDown"), exports);
|
|
19
|
+
__exportStar(require("./usePasswordStrength"), exports);
|
|
20
|
+
__exportStar(require("./useRefocusOnActivator"), exports);
|
|
21
|
+
__exportStar(require("./useResizeObserver"), exports);
|
package/dist/useAssert/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var useAssert_1 = require("./useAssert");
|
|
4
|
-
exports
|
|
4
|
+
Object.defineProperty(exports, "useAssert", { enumerable: true, get: function () { return useAssert_1.useAssert; } });
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useAssert = void 0;
|
|
6
7
|
var process_1 = __importDefault(require("process"));
|
|
7
8
|
function useAssert(shouldShow, message, options) {
|
|
8
9
|
if (process_1.default.env.NODE_ENV !== "production" && shouldShow) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var useCollectionQuery_1 = require("./useCollectionQuery");
|
|
4
|
-
exports
|
|
4
|
+
Object.defineProperty(exports, "useCollectionQuery", { enumerable: true, get: function () { return useCollectionQuery_1.useCollectionQuery; } });
|
|
@@ -4,8 +4,9 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.returnValues = exports.subscriptionPropsList = exports.propsList = exports.getLoadingState = exports.apolloClient = exports.LIST_QUERY = void 0;
|
|
7
8
|
var client_1 = require("@apollo/client");
|
|
8
|
-
exports.LIST_QUERY = client_1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query ListQuery($cursor: String) {\n allPlanets(first: 4, after: $cursor) {\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n name\n id\n }\n cursor\n }\n
|
|
9
|
+
exports.LIST_QUERY = client_1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query ListQuery($cursor: String) {\n allPlanets(first: 4, after: $cursor) {\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n name\n id\n }\n cursor\n }\n }\n }\n"], ["\n query ListQuery($cursor: String) {\n allPlanets(first: 4, after: $cursor) {\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n name\n id\n }\n cursor\n }\n }\n }\n"])));
|
|
9
10
|
exports.apolloClient = new client_1.ApolloClient({
|
|
10
11
|
uri: "https://swapi-graphql.netlify.app/.netlify/functions/index",
|
|
11
12
|
cache: new client_1.InMemoryCache(),
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
5
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
__exportStar(require("./queries"), exports);
|
|
14
|
+
__exportStar(require("./utils"), exports);
|
|
15
|
+
__exportStar(require("./mocks"), exports);
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
+
import { DocumentNode } from "@apollo/client";
|
|
2
3
|
import { MockedResponse } from "@apollo/react-testing";
|
|
3
4
|
import React from "react";
|
|
4
5
|
export declare function wrapper(mocks: MockedResponse[]): React.FunctionComponent<{}>;
|
|
5
6
|
export declare const listQueryResponseMock: jest.Mock<{
|
|
7
|
+
data: {
|
|
8
|
+
conversation: {
|
|
9
|
+
__typename: string;
|
|
10
|
+
smsMessages: {
|
|
11
|
+
__typename: string;
|
|
12
|
+
edges: {
|
|
13
|
+
__typename: string;
|
|
14
|
+
node: {
|
|
15
|
+
__typename: string;
|
|
16
|
+
id: any;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
nodes: {
|
|
20
|
+
__typename: string;
|
|
21
|
+
id: any;
|
|
22
|
+
}[];
|
|
23
|
+
pageInfo: {
|
|
24
|
+
__typename: string;
|
|
25
|
+
endCursor: string;
|
|
26
|
+
hasNextPage: boolean;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}, [any]>;
|
|
32
|
+
export declare const listQueryWithTotalCountResponseMock: jest.Mock<{
|
|
6
33
|
data: {
|
|
7
34
|
conversation: {
|
|
8
35
|
__typename: string;
|
|
@@ -41,44 +68,18 @@ export declare const subscriptionQueryMock: jest.Mock<{
|
|
|
41
68
|
};
|
|
42
69
|
};
|
|
43
70
|
}, [any]>;
|
|
44
|
-
export declare function buildListRequestMock(id?: string | undefined, searchTerm?: string | undefined): {
|
|
71
|
+
export declare function buildListRequestMock(query: DocumentNode, responseMock: jest.Mock, id?: string | undefined, searchTerm?: string | undefined): {
|
|
45
72
|
request: {
|
|
46
|
-
query:
|
|
73
|
+
query: DocumentNode;
|
|
47
74
|
variables: {
|
|
48
75
|
searchTerm: string | undefined;
|
|
49
76
|
};
|
|
50
77
|
};
|
|
51
|
-
result: () =>
|
|
52
|
-
data: {
|
|
53
|
-
conversation: {
|
|
54
|
-
__typename: string;
|
|
55
|
-
smsMessages: {
|
|
56
|
-
__typename: string;
|
|
57
|
-
edges: {
|
|
58
|
-
__typename: string;
|
|
59
|
-
node: {
|
|
60
|
-
__typename: string;
|
|
61
|
-
id: any;
|
|
62
|
-
};
|
|
63
|
-
}[];
|
|
64
|
-
nodes: {
|
|
65
|
-
__typename: string;
|
|
66
|
-
id: any;
|
|
67
|
-
}[];
|
|
68
|
-
pageInfo: {
|
|
69
|
-
__typename: string;
|
|
70
|
-
endCursor: string;
|
|
71
|
-
hasNextPage: boolean;
|
|
72
|
-
};
|
|
73
|
-
totalCount: number;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
+
result: () => any;
|
|
78
79
|
};
|
|
79
80
|
export declare function buildSubscriptionRequestMock(id?: string | undefined): {
|
|
80
81
|
request: {
|
|
81
|
-
query:
|
|
82
|
+
query: DocumentNode;
|
|
82
83
|
};
|
|
83
84
|
result: () => {
|
|
84
85
|
data: {
|
|
@@ -94,39 +95,13 @@ export declare function buildSubscriptionRequestMock(id?: string | undefined): {
|
|
|
94
95
|
};
|
|
95
96
|
delay: number;
|
|
96
97
|
};
|
|
97
|
-
export declare function buildListRequestMockForNextPage(id?: string | undefined): {
|
|
98
|
+
export declare function buildListRequestMockForNextPage(query: DocumentNode, responseMock: jest.Mock, id?: string | undefined): {
|
|
98
99
|
request: {
|
|
99
|
-
query:
|
|
100
|
+
query: DocumentNode;
|
|
100
101
|
variables: {
|
|
101
102
|
cursor: string;
|
|
102
103
|
};
|
|
103
104
|
};
|
|
104
|
-
result: () =>
|
|
105
|
-
data: {
|
|
106
|
-
conversation: {
|
|
107
|
-
__typename: string;
|
|
108
|
-
smsMessages: {
|
|
109
|
-
__typename: string;
|
|
110
|
-
edges: {
|
|
111
|
-
__typename: string;
|
|
112
|
-
node: {
|
|
113
|
-
__typename: string;
|
|
114
|
-
id: any;
|
|
115
|
-
};
|
|
116
|
-
}[];
|
|
117
|
-
nodes: {
|
|
118
|
-
__typename: string;
|
|
119
|
-
id: any;
|
|
120
|
-
}[];
|
|
121
|
-
pageInfo: {
|
|
122
|
-
__typename: string;
|
|
123
|
-
endCursor: string;
|
|
124
|
-
hasNextPage: boolean;
|
|
125
|
-
};
|
|
126
|
-
totalCount: number;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
};
|
|
105
|
+
result: () => any;
|
|
131
106
|
};
|
|
132
107
|
export declare function setListQueryMockHasNextPage(hasNextPage: boolean): void;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setListQueryMockHasNextPage = exports.buildListRequestMockForNextPage = exports.buildSubscriptionRequestMock = exports.buildListRequestMock = exports.subscriptionQueryMock = exports.listQueryWithTotalCountResponseMock = exports.listQueryResponseMock = exports.wrapper = void 0;
|
|
6
7
|
var react_testing_1 = require("@apollo/react-testing");
|
|
7
8
|
var react_1 = __importDefault(require("react"));
|
|
8
9
|
var uuid_1 = require("uuid");
|
|
@@ -17,6 +18,38 @@ function wrapper(mocks) {
|
|
|
17
18
|
exports.wrapper = wrapper;
|
|
18
19
|
var listQueryHasNextPage = true;
|
|
19
20
|
exports.listQueryResponseMock = jest.fn(function (id) {
|
|
21
|
+
return {
|
|
22
|
+
data: {
|
|
23
|
+
conversation: {
|
|
24
|
+
__typename: "Conversation",
|
|
25
|
+
smsMessages: {
|
|
26
|
+
__typename: "SMSMessageConnection",
|
|
27
|
+
edges: [
|
|
28
|
+
{
|
|
29
|
+
__typename: "SMSMessageEdge",
|
|
30
|
+
node: {
|
|
31
|
+
__typename: "SMSMessage",
|
|
32
|
+
id: id || uuid_1.v1(),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
nodes: [
|
|
37
|
+
{
|
|
38
|
+
__typename: "SMSMessage",
|
|
39
|
+
id: id || uuid_1.v1(),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
pageInfo: {
|
|
43
|
+
__typename: "PageInfo",
|
|
44
|
+
endCursor: "MZ",
|
|
45
|
+
hasNextPage: listQueryHasNextPage,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
exports.listQueryWithTotalCountResponseMock = jest.fn(function (id) {
|
|
20
53
|
return {
|
|
21
54
|
data: {
|
|
22
55
|
conversation: {
|
|
@@ -63,13 +96,13 @@ exports.subscriptionQueryMock = jest.fn(function (id) {
|
|
|
63
96
|
},
|
|
64
97
|
};
|
|
65
98
|
});
|
|
66
|
-
function buildListRequestMock(id, searchTerm) {
|
|
99
|
+
function buildListRequestMock(query, responseMock, id, searchTerm) {
|
|
67
100
|
return {
|
|
68
101
|
request: {
|
|
69
|
-
query:
|
|
102
|
+
query: query,
|
|
70
103
|
variables: { searchTerm: searchTerm },
|
|
71
104
|
},
|
|
72
|
-
result: function () { return
|
|
105
|
+
result: function () { return responseMock(id); },
|
|
73
106
|
};
|
|
74
107
|
}
|
|
75
108
|
exports.buildListRequestMock = buildListRequestMock;
|
|
@@ -83,13 +116,13 @@ function buildSubscriptionRequestMock(id) {
|
|
|
83
116
|
};
|
|
84
117
|
}
|
|
85
118
|
exports.buildSubscriptionRequestMock = buildSubscriptionRequestMock;
|
|
86
|
-
function buildListRequestMockForNextPage(id) {
|
|
119
|
+
function buildListRequestMockForNextPage(query, responseMock, id) {
|
|
87
120
|
return {
|
|
88
121
|
request: {
|
|
89
|
-
query:
|
|
122
|
+
query: query,
|
|
90
123
|
variables: { cursor: "MZ" },
|
|
91
124
|
},
|
|
92
|
-
result: function () { return
|
|
125
|
+
result: function () { return responseMock(id); },
|
|
93
126
|
};
|
|
94
127
|
}
|
|
95
128
|
exports.buildListRequestMockForNextPage = buildListRequestMockForNextPage;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const LIST_QUERY: import("@apollo/client").DocumentNode;
|
|
2
|
+
export declare const LIST_QUERY_WITH_TOTAL_COUNT: import("@apollo/client").DocumentNode;
|
|
2
3
|
export interface ListQueryType {
|
|
3
4
|
__typename?: "Query";
|
|
4
5
|
conversation?: {
|
|
@@ -20,7 +21,7 @@ export interface ListQueryType {
|
|
|
20
21
|
endCursor: string;
|
|
21
22
|
hasNextPage: boolean;
|
|
22
23
|
};
|
|
23
|
-
totalCount
|
|
24
|
+
totalCount?: number;
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
}
|
|
@@ -4,7 +4,9 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SUBSCRIPTION_QUERY = exports.LIST_QUERY_WITH_TOTAL_COUNT = exports.LIST_QUERY = void 0;
|
|
7
8
|
var client_1 = require("@apollo/client");
|
|
8
|
-
exports.LIST_QUERY = client_1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query ConversationMessages($cursor: string, $searchTerm: string) {\n conversation(id: \"MQ==\") {\n smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {\n edges {\n node {\n __typename\n id\n }\n }\n nodes {\n __typename\n id\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n
|
|
9
|
-
exports.
|
|
10
|
-
|
|
9
|
+
exports.LIST_QUERY = client_1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query ConversationMessages($cursor: string, $searchTerm: string) {\n conversation(id: \"MQ==\") {\n smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {\n edges {\n node {\n __typename\n id\n }\n }\n nodes {\n __typename\n id\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n"], ["\n query ConversationMessages($cursor: string, $searchTerm: string) {\n conversation(id: \"MQ==\") {\n smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {\n edges {\n node {\n __typename\n id\n }\n }\n nodes {\n __typename\n id\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n"])));
|
|
10
|
+
exports.LIST_QUERY_WITH_TOTAL_COUNT = client_1.gql(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query ConversationMessages($cursor: string, $searchTerm: string) {\n conversation(id: \"MQ==\") {\n smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {\n edges {\n node {\n __typename\n id\n }\n }\n nodes {\n __typename\n id\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n totalCount\n }\n }\n }\n"], ["\n query ConversationMessages($cursor: string, $searchTerm: string) {\n conversation(id: \"MQ==\") {\n smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {\n edges {\n node {\n __typename\n id\n }\n }\n nodes {\n __typename\n id\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n totalCount\n }\n }\n }\n"])));
|
|
11
|
+
exports.SUBSCRIPTION_QUERY = client_1.gql(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n subscription ConversationMessage($conversationId: EncodedId!) {\n conversationMessage(conversationId: $conversationId) {\n smsMessage {\n __typename\n id\n }\n }\n }\n"], ["\n subscription ConversationMessage($conversationId: EncodedId!) {\n conversationMessage(conversationId: $conversationId) {\n smsMessage {\n __typename\n id\n }\n }\n }\n"])));
|
|
12
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.wait = void 0;
|
|
39
40
|
function wait(milliseconds) {
|
|
40
41
|
if (milliseconds === void 0) { milliseconds = 0; }
|
|
41
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -31,6 +31,7 @@ var __spread = (this && this.__spread) || function () {
|
|
|
31
31
|
return ar;
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.isAlreadyUpdated = exports.useCollectionQuery = void 0;
|
|
34
35
|
var client_1 = require("@apollo/client");
|
|
35
36
|
var lodash_1 = require("lodash");
|
|
36
37
|
var react_1 = require("react");
|
|
@@ -39,8 +40,8 @@ var uniqueNodes_1 = require("./uniqueNodes");
|
|
|
39
40
|
var uniqueEdges_1 = require("./uniqueEdges");
|
|
40
41
|
var useIsMounted_1 = require("../useIsMounted");
|
|
41
42
|
function useCollectionQuery(_a) {
|
|
42
|
-
var query = _a.query, queryOptions = _a.queryOptions, getCollectionByPath = _a.getCollectionByPath, subscription = _a.subscription;
|
|
43
43
|
var _b, _c;
|
|
44
|
+
var query = _a.query, queryOptions = _a.queryOptions, getCollectionByPath = _a.getCollectionByPath, subscription = _a.subscription;
|
|
44
45
|
var _d = client_1.useQuery(query, queryOptions), data = _d.data, loading = _d.loading, refetch = _d.refetch, error = _d.error, fetchMore = _d.fetchMore, subscribeToMore = _d.subscribeToMore;
|
|
45
46
|
var isMounted = useIsMounted_1.useIsMounted();
|
|
46
47
|
var _e = __read(react_1.useState(false), 2), loadingRefresh = _e[0], setLoadingRefresh = _e[1];
|
|
@@ -165,10 +166,7 @@ function fetchMoreUpdateQueryHandler(prev, fetchMoreResult, getCollectionByPath)
|
|
|
165
166
|
if (outputCollection.edges && nextCollection.edges) {
|
|
166
167
|
outputCollection.edges = getUpdatedEdges(outputCollection.edges, nextCollection.edges);
|
|
167
168
|
}
|
|
168
|
-
Object.assign(outputCollection, {
|
|
169
|
-
pageInfo: lodash_1.cloneDeep(nextCollection.pageInfo),
|
|
170
|
-
totalCount: nextCollection.totalCount,
|
|
171
|
-
});
|
|
169
|
+
Object.assign(outputCollection, __assign({ pageInfo: lodash_1.cloneDeep(nextCollection.pageInfo) }, getTotalCount(nextCollection.totalCount)));
|
|
172
170
|
return output;
|
|
173
171
|
}
|
|
174
172
|
function subscribeToMoreHandler(isSearching, prev, getCollectionByPath, subscriptionData, getNodeByPath) {
|
|
@@ -186,12 +184,15 @@ function subscribeToMoreHandler(isSearching, prev, getCollectionByPath, subscrip
|
|
|
186
184
|
if (outputCollection.edges) {
|
|
187
185
|
outputCollection.edges = getUpdatedEdges(outputCollection.edges, [uniqueEdges_1.createEdge(node)], false);
|
|
188
186
|
}
|
|
189
|
-
Object.assign(outputCollection, {
|
|
190
|
-
pageInfo: lodash_1.cloneDeep(outputCollection.pageInfo),
|
|
191
|
-
totalCount: outputCollection.totalCount + 1,
|
|
192
|
-
});
|
|
187
|
+
Object.assign(outputCollection, __assign({ pageInfo: lodash_1.cloneDeep(outputCollection.pageInfo) }, getTotalCount(outputCollection.totalCount, 1)));
|
|
193
188
|
return output;
|
|
194
189
|
}
|
|
190
|
+
function getTotalCount(totalCount, additionalCount) {
|
|
191
|
+
if (additionalCount === void 0) { additionalCount = 0; }
|
|
192
|
+
return totalCount !== undefined
|
|
193
|
+
? { totalCount: totalCount + additionalCount }
|
|
194
|
+
: {};
|
|
195
|
+
}
|
|
195
196
|
function isAlreadyUpdated(outputCollection, newNode) {
|
|
196
197
|
var edgesAlreadyUpdated = true;
|
|
197
198
|
var nodesAlreadyUpdated = true;
|