@quesmed/types-rn 2.2.95 → 2.2.97
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/package.json
CHANGED
|
@@ -34,7 +34,7 @@ const updateNotificatonsOnMarkAsRead = (cache, result, options) => {
|
|
|
34
34
|
...notifications.slice(index + 1),
|
|
35
35
|
].sort((n1, n2) => {
|
|
36
36
|
if (n1.read === n2.read) {
|
|
37
|
-
return n1.createdAt
|
|
37
|
+
return n1.createdAt > n2.createdAt ? -1 : 1;
|
|
38
38
|
}
|
|
39
39
|
return n1.read ? 1 : -1;
|
|
40
40
|
});
|
|
@@ -25,6 +25,7 @@ export interface ISaveTodosVar {
|
|
|
25
25
|
}
|
|
26
26
|
export declare type ISaveTodosData = RestrictedData<(graphqlNormalize & ITodo)[], 'saveTodos'>;
|
|
27
27
|
export declare function saveTodosCache(cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<ISaveTodosData>, options: ApolloUpdateOptions): void;
|
|
28
|
+
export declare const optimisticSaveTodos: (todo: ITodo, cardIndex: number, todoInput: ITodoInput) => ISaveTodosData;
|
|
28
29
|
export declare const ADD_TO_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
29
30
|
export interface IAddToDailyStackVar {
|
|
30
31
|
conceptIds: Id[];
|
|
@@ -37,8 +38,8 @@ export interface IRemoveFromDailyStackVar {
|
|
|
37
38
|
conceptId?: Id;
|
|
38
39
|
}
|
|
39
40
|
export declare type IRemoveFromDailyStackData = RestrictedData<(graphqlNormalize & IUserCompletedCard)[], 'removeFromDailyStack'>;
|
|
40
|
-
export declare const
|
|
41
|
-
export declare const
|
|
41
|
+
export declare const updateCacheOnRemoveFromDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>, options: ApolloUpdateOptions) => void;
|
|
42
|
+
export declare const updateCacheOnAddToDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
42
43
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
43
44
|
export declare type IRefreshDailyTaskVar = null;
|
|
44
45
|
export declare type IRefreshDailyTaskData = RestrictedData<graphqlNormalize & ITodo, 'refreshDailyTask'>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REFRESH_DAILY_TASK = exports.
|
|
3
|
+
exports.REFRESH_DAILY_TASK = exports.updateCacheOnAddToDailyStack = exports.updateCacheOnRemoveFromDailyStack = exports.REMOVE_FROM_DAILY_STACK = exports.ADD_TO_DAILY_STACK = exports.optimisticSaveTodos = exports.saveTodosCache = exports.SAVE_TODO = exports.BUILD_TODO = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
5
|
const fragments_1 = require("../../fragments");
|
|
6
|
+
const restricted_1 = require("../../query/restricted");
|
|
6
7
|
exports.BUILD_TODO = (0, client_1.gql) `
|
|
7
8
|
mutation BuildTodo($buildTodo: BuildTodoInput!) {
|
|
8
9
|
restricted {
|
|
@@ -78,6 +79,23 @@ function saveTodosCache(cache, result, options) {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
exports.saveTodosCache = saveTodosCache;
|
|
82
|
+
const optimisticSaveTodos = (todo, cardIndex, todoInput) => {
|
|
83
|
+
const { score, timeTaken } = todoInput;
|
|
84
|
+
const { marks } = todo;
|
|
85
|
+
const newMarks = [...marks];
|
|
86
|
+
newMarks[cardIndex] = { ...marks[cardIndex], score, timeTaken };
|
|
87
|
+
return {
|
|
88
|
+
restricted: {
|
|
89
|
+
saveTodos: [
|
|
90
|
+
{
|
|
91
|
+
...todo,
|
|
92
|
+
marks: newMarks,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.optimisticSaveTodos = optimisticSaveTodos;
|
|
81
99
|
exports.ADD_TO_DAILY_STACK = (0, client_1.gql) `
|
|
82
100
|
${fragments_1.PICTURE_FIELDS}
|
|
83
101
|
mutation AddToDailyStack($conceptIds: [Int!]!) {
|
|
@@ -135,49 +153,85 @@ exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
|
|
|
135
153
|
}
|
|
136
154
|
}
|
|
137
155
|
`;
|
|
138
|
-
const
|
|
156
|
+
const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
139
157
|
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
const { variables } = options || {};
|
|
159
|
+
const { todoId } = variables || {};
|
|
160
|
+
if (!removeFromDailyStack || !removeFromDailyStack.length) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const toRemove = new Set(removeFromDailyStack.map(({ cardId }) => cardId));
|
|
164
|
+
const prevData = cache.readQuery({
|
|
165
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
143
166
|
});
|
|
144
|
-
if (prevData
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
const newCompletedCards = prevData.completedCards.filter(({ id }) => !toRemove.has(id));
|
|
150
|
-
cache.writeFragment({
|
|
151
|
-
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
167
|
+
if (prevData) {
|
|
168
|
+
const newCompletedCards = prevData.restricted.user.completedCards.filter(({ cardId }) => !toRemove.has(cardId));
|
|
169
|
+
cache.writeQuery({
|
|
170
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
152
171
|
data: {
|
|
153
|
-
|
|
154
|
-
|
|
172
|
+
...prevData,
|
|
173
|
+
restricted: {
|
|
174
|
+
...prevData.restricted,
|
|
175
|
+
user: {
|
|
176
|
+
...prevData.restricted.user,
|
|
177
|
+
completedCards: newCompletedCards,
|
|
178
|
+
completedCardsCount: newCompletedCards.length,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
155
181
|
},
|
|
156
|
-
fragment: fragments_1.COMPLETED_CARDS,
|
|
157
182
|
});
|
|
158
183
|
}
|
|
184
|
+
if (todoId) {
|
|
185
|
+
const prevData = cache.readQuery({
|
|
186
|
+
variables: { id: todoId },
|
|
187
|
+
query: restricted_1.TODO,
|
|
188
|
+
});
|
|
189
|
+
if (prevData) {
|
|
190
|
+
const { marks } = prevData.restricted.todo;
|
|
191
|
+
cache.writeQuery({
|
|
192
|
+
query: restricted_1.TODO,
|
|
193
|
+
data: {
|
|
194
|
+
...prevData,
|
|
195
|
+
restricted: {
|
|
196
|
+
...prevData.restricted,
|
|
197
|
+
todo: {
|
|
198
|
+
...prevData.restricted.todo,
|
|
199
|
+
marks: marks.filter(({ cardId }) => !toRemove.has(Number(cardId))),
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
159
206
|
};
|
|
160
|
-
exports.
|
|
161
|
-
const
|
|
207
|
+
exports.updateCacheOnRemoveFromDailyStack = updateCacheOnRemoveFromDailyStack;
|
|
208
|
+
const updateCacheOnAddToDailyStack = (cache, result) => {
|
|
162
209
|
const { addToDailyStack } = result.data?.restricted || {};
|
|
163
|
-
const prevData = cache.
|
|
164
|
-
|
|
165
|
-
fragment: fragments_1.COMPLETED_CARDS,
|
|
210
|
+
const prevData = cache.readQuery({
|
|
211
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
166
212
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
213
|
+
if (prevData && addToDailyStack) {
|
|
214
|
+
const newCompletedCards = [
|
|
215
|
+
...prevData.restricted.user.completedCards,
|
|
216
|
+
...addToDailyStack,
|
|
217
|
+
];
|
|
218
|
+
cache.writeQuery({
|
|
219
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
172
220
|
data: {
|
|
173
|
-
|
|
174
|
-
|
|
221
|
+
...prevData,
|
|
222
|
+
restricted: {
|
|
223
|
+
...prevData.restricted,
|
|
224
|
+
user: {
|
|
225
|
+
...prevData.restricted.user,
|
|
226
|
+
completedCards: newCompletedCards,
|
|
227
|
+
completedCardsCount: newCompletedCards.length,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
175
230
|
},
|
|
176
|
-
fragment: fragments_1.COMPLETED_CARDS,
|
|
177
231
|
});
|
|
178
232
|
}
|
|
179
233
|
};
|
|
180
|
-
exports.
|
|
234
|
+
exports.updateCacheOnAddToDailyStack = updateCacheOnAddToDailyStack;
|
|
181
235
|
exports.REFRESH_DAILY_TASK = (0, client_1.gql) `
|
|
182
236
|
${fragments_1.PICTURE_FIELDS}
|
|
183
237
|
mutation RefreshDailyTask {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ApolloClient } from '@apollo/client';
|
|
2
|
-
import { IMarksheetInput } from './restricted';
|
|
2
|
+
import { IMarksheetInput, ITodoInput } from './restricted';
|
|
3
3
|
export declare const saveSampleMarksheets: (client: ApolloClient<any>, marksheetInput: IMarksheetInput, questionIndex: number) => void;
|
|
4
|
+
export declare const saveSampleTodoMark: (client: ApolloClient<any>, todoInput: ITodoInput, markId: number) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveSampleMarksheets = void 0;
|
|
3
|
+
exports.saveSampleTodoMark = exports.saveSampleMarksheets = void 0;
|
|
4
|
+
const client_1 = require("@apollo/client");
|
|
4
5
|
const query_1 = require("../query");
|
|
5
6
|
const saveSampleMarksheets = (client, marksheetInput, questionIndex) => {
|
|
6
7
|
const { timeTaken, choiceId, mark, marksheetId } = marksheetInput;
|
|
@@ -35,3 +36,20 @@ const saveSampleMarksheets = (client, marksheetInput, questionIndex) => {
|
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
exports.saveSampleMarksheets = saveSampleMarksheets;
|
|
39
|
+
const saveSampleTodoMark = (client, todoInput, markId) => {
|
|
40
|
+
const { timeTaken, score } = todoInput;
|
|
41
|
+
client.writeFragment({
|
|
42
|
+
id: `TodoMark:${markId}`,
|
|
43
|
+
data: {
|
|
44
|
+
score,
|
|
45
|
+
timeTaken: timeTaken,
|
|
46
|
+
},
|
|
47
|
+
fragment: (0, client_1.gql) `
|
|
48
|
+
fragment UpdatedTodoMark on TodoMark {
|
|
49
|
+
score
|
|
50
|
+
timeTaken
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
exports.saveSampleTodoMark = saveSampleTodoMark;
|