@quesmed/types 2.2.67 → 2.2.71
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/cjs/resolvers/fragments/user.d.ts +1 -0
- package/dist/cjs/resolvers/fragments/user.js +40 -1
- package/dist/cjs/resolvers/mutation/restricted/marksheet.d.ts +3 -0
- package/dist/cjs/resolvers/mutation/restricted/marksheet.js +63 -23
- package/dist/cjs/resolvers/mutation/restricted/todo.d.ts +2 -0
- package/dist/cjs/resolvers/mutation/restricted/todo.js +44 -1
- package/dist/cjs/resolvers/mutation/restricted/users.d.ts +1 -0
- package/dist/mjs/resolvers/fragments/user.d.ts +1 -0
- package/dist/mjs/resolvers/fragments/user.js +39 -0
- package/dist/mjs/resolvers/mutation/restricted/marksheet.d.ts +3 -0
- package/dist/mjs/resolvers/mutation/restricted/marksheet.js +60 -22
- package/dist/mjs/resolvers/mutation/restricted/todo.d.ts +2 -0
- package/dist/mjs/resolvers/mutation/restricted/todo.js +42 -1
- package/dist/mjs/resolvers/mutation/restricted/users.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.USER_FIELDS = void 0;
|
|
3
|
+
exports.COMPLETED_CARDS = exports.USER_FIELDS = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
|
+
const picture_1 = require("./picture");
|
|
5
6
|
exports.USER_FIELDS = (0, client_1.gql) `
|
|
6
7
|
fragment UserFields on User {
|
|
7
8
|
id
|
|
@@ -34,3 +35,41 @@ exports.USER_FIELDS = (0, client_1.gql) `
|
|
|
34
35
|
# completedRedCardsCount
|
|
35
36
|
}
|
|
36
37
|
`;
|
|
38
|
+
exports.COMPLETED_CARDS = (0, client_1.gql) `
|
|
39
|
+
${picture_1.PICTURE_FIELDS}
|
|
40
|
+
fragment UserCompletedCards on User {
|
|
41
|
+
completedCards {
|
|
42
|
+
id
|
|
43
|
+
createdAt
|
|
44
|
+
updatedAt
|
|
45
|
+
concept {
|
|
46
|
+
id
|
|
47
|
+
name
|
|
48
|
+
}
|
|
49
|
+
lastSeen
|
|
50
|
+
reviewDate
|
|
51
|
+
score
|
|
52
|
+
iteration
|
|
53
|
+
optimalFactor
|
|
54
|
+
cardId
|
|
55
|
+
card {
|
|
56
|
+
id
|
|
57
|
+
conceptId
|
|
58
|
+
concept {
|
|
59
|
+
id
|
|
60
|
+
name
|
|
61
|
+
}
|
|
62
|
+
topic {
|
|
63
|
+
id
|
|
64
|
+
name
|
|
65
|
+
}
|
|
66
|
+
question
|
|
67
|
+
explanation
|
|
68
|
+
pictures {
|
|
69
|
+
...PictureFields
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
completedCardsCount
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
@@ -73,6 +73,9 @@ export interface IRemoveFlaggedQuestionVar {
|
|
|
73
73
|
questionId: Id;
|
|
74
74
|
}
|
|
75
75
|
export declare type IRemoveFlaggedQuestionData = RestrictedData<(graphqlNormalize & IUserFlaggedQuestion)[], 'removeFlaggedQuestion'>;
|
|
76
|
+
export declare const MARK_FLAGGED_FIELD: import("@apollo/client").DocumentNode;
|
|
77
|
+
export declare const updateCacheAddFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddFlaggedQuestionData>) => void;
|
|
78
|
+
export declare const updateCacheRemoveFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFlaggedQuestionData>) => void;
|
|
76
79
|
/**
|
|
77
80
|
* startOrJoinMarksheet
|
|
78
81
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOGGLE_STRIKE_OPTIONS = exports.END_MARKSHEET = exports.LEAVE_MARKSHEET = exports.MODIFY_MARKSHEET_INFO = exports.optimisticModifyMarksheetBuilderConfig = exports.START_OR_JOIN_MARKSHEET = exports.REMOVE_FLAGGED_QUESTION = exports.ADD_FLAGGED_QUESTION = exports.optimisticSaveMarksheets = exports.updateMarksheets = exports.SAVE_MARKSHEET = exports.RE_BUILD_MARKSHEET = exports.BUILD_MARKSHEET = exports.BUILD_QUESTION_MARKSHEET = void 0;
|
|
3
|
+
exports.TOGGLE_STRIKE_OPTIONS = exports.END_MARKSHEET = exports.LEAVE_MARKSHEET = exports.MODIFY_MARKSHEET_INFO = exports.optimisticModifyMarksheetBuilderConfig = exports.START_OR_JOIN_MARKSHEET = exports.updateCacheRemoveFlaggedQuestion = exports.updateCacheAddFlaggedQuestion = exports.MARK_FLAGGED_FIELD = exports.REMOVE_FLAGGED_QUESTION = exports.ADD_FLAGGED_QUESTION = exports.optimisticSaveMarksheets = exports.updateMarksheets = exports.SAVE_MARKSHEET = exports.RE_BUILD_MARKSHEET = exports.BUILD_MARKSHEET = exports.BUILD_QUESTION_MARKSHEET = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
5
|
const restricted_1 = require("../../query/restricted");
|
|
6
6
|
exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
@@ -1138,14 +1138,29 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1138
1138
|
restricted {
|
|
1139
1139
|
reBuildMarksheet(marksheetId: $marksheetId) {
|
|
1140
1140
|
id
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1141
|
+
topicConceptData
|
|
1142
|
+
currentMarkId
|
|
1143
|
+
completed
|
|
1144
|
+
timeTaken
|
|
1144
1145
|
topicIds
|
|
1145
1146
|
topicNames
|
|
1147
|
+
mockTestId
|
|
1148
|
+
totalQuestions
|
|
1149
|
+
solo
|
|
1150
|
+
agoraId
|
|
1146
1151
|
state
|
|
1147
|
-
|
|
1148
|
-
|
|
1152
|
+
user {
|
|
1153
|
+
id
|
|
1154
|
+
displayName
|
|
1155
|
+
}
|
|
1156
|
+
users {
|
|
1157
|
+
id
|
|
1158
|
+
displayName
|
|
1159
|
+
}
|
|
1160
|
+
activeUsers {
|
|
1161
|
+
id
|
|
1162
|
+
displayName
|
|
1163
|
+
}
|
|
1149
1164
|
builderConfig {
|
|
1150
1165
|
difficulty
|
|
1151
1166
|
isTest
|
|
@@ -1161,19 +1176,13 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1161
1176
|
seenIncorrect
|
|
1162
1177
|
unseen
|
|
1163
1178
|
}
|
|
1179
|
+
createdAt
|
|
1180
|
+
startedAt
|
|
1181
|
+
endedAt
|
|
1182
|
+
isTestMarksheet
|
|
1164
1183
|
source
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
displayName
|
|
1168
|
-
}
|
|
1169
|
-
users {
|
|
1170
|
-
id
|
|
1171
|
-
displayName
|
|
1172
|
-
}
|
|
1173
|
-
user {
|
|
1174
|
-
displayName
|
|
1175
|
-
id
|
|
1176
|
-
}
|
|
1184
|
+
correct
|
|
1185
|
+
incorrect
|
|
1177
1186
|
marks {
|
|
1178
1187
|
id
|
|
1179
1188
|
flagged
|
|
@@ -1683,11 +1692,6 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1683
1692
|
}
|
|
1684
1693
|
}
|
|
1685
1694
|
}
|
|
1686
|
-
mockTestId
|
|
1687
|
-
correct
|
|
1688
|
-
incorrect
|
|
1689
|
-
totalQuestions
|
|
1690
|
-
isTestMarksheet
|
|
1691
1695
|
}
|
|
1692
1696
|
}
|
|
1693
1697
|
}
|
|
@@ -1817,6 +1821,42 @@ exports.REMOVE_FLAGGED_QUESTION = (0, client_1.gql) `
|
|
|
1817
1821
|
}
|
|
1818
1822
|
}
|
|
1819
1823
|
`;
|
|
1824
|
+
exports.MARK_FLAGGED_FIELD = (0, client_1.gql) `
|
|
1825
|
+
fragment MarksheetMarkFlagged on MarksheetMark {
|
|
1826
|
+
flagged
|
|
1827
|
+
}
|
|
1828
|
+
`;
|
|
1829
|
+
const updateCacheAddFlaggedQuestion = (cache, result) => {
|
|
1830
|
+
const { addFlaggedQuestion } = result?.data?.restricted || {};
|
|
1831
|
+
if (!addFlaggedQuestion) {
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
const { markId } = addFlaggedQuestion;
|
|
1835
|
+
cache.writeFragment({
|
|
1836
|
+
id: cache.identify({ id: markId, __typename: 'MarksheetMark' }),
|
|
1837
|
+
data: {
|
|
1838
|
+
flagged: true,
|
|
1839
|
+
},
|
|
1840
|
+
fragment: exports.MARK_FLAGGED_FIELD,
|
|
1841
|
+
});
|
|
1842
|
+
};
|
|
1843
|
+
exports.updateCacheAddFlaggedQuestion = updateCacheAddFlaggedQuestion;
|
|
1844
|
+
const updateCacheRemoveFlaggedQuestion = (cache, result) => {
|
|
1845
|
+
const { removeFlaggedQuestion } = result?.data?.restricted || {};
|
|
1846
|
+
if (!removeFlaggedQuestion) {
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
removeFlaggedQuestion.forEach(({ markId }) => {
|
|
1850
|
+
cache.writeFragment({
|
|
1851
|
+
id: cache.identify({ id: Number(markId), __typename: 'MarksheetMark' }),
|
|
1852
|
+
data: {
|
|
1853
|
+
flagged: false,
|
|
1854
|
+
},
|
|
1855
|
+
fragment: exports.MARK_FLAGGED_FIELD,
|
|
1856
|
+
});
|
|
1857
|
+
});
|
|
1858
|
+
};
|
|
1859
|
+
exports.updateCacheRemoveFlaggedQuestion = updateCacheRemoveFlaggedQuestion;
|
|
1820
1860
|
exports.START_OR_JOIN_MARKSHEET = (0, client_1.gql) `
|
|
1821
1861
|
mutation StartOrJoinMarksheet($agoraId: String!, $solo: Boolean!) {
|
|
1822
1862
|
restricted {
|
|
@@ -37,6 +37,8 @@ export interface IRemoveFromDailyStackVar {
|
|
|
37
37
|
conceptId?: Id;
|
|
38
38
|
}
|
|
39
39
|
export declare type IRemoveFromDailyStackData = RestrictedData<(graphqlNormalize & IUserCompletedCard)[], 'removeFromDailyStack'>;
|
|
40
|
+
export declare const updateCacheRemoveFromDailyStack: (userId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>) => void;
|
|
41
|
+
export declare const updateCacheAddToDailyStack: (userId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
40
42
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
41
43
|
export declare type IRefreshDailyTaskVar = null;
|
|
42
44
|
export declare type IRefreshDailyTaskData = RestrictedData<graphqlNormalize & ITodo, 'refreshDailyTask'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REFRESH_DAILY_TASK = exports.REMOVE_FROM_DAILY_STACK = exports.ADD_TO_DAILY_STACK = exports.saveTodosCache = exports.SAVE_TODO = exports.BUILD_TODO = void 0;
|
|
3
|
+
exports.REFRESH_DAILY_TASK = exports.updateCacheAddToDailyStack = exports.updateCacheRemoveFromDailyStack = exports.REMOVE_FROM_DAILY_STACK = exports.ADD_TO_DAILY_STACK = 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
6
|
exports.BUILD_TODO = (0, client_1.gql) `
|
|
@@ -134,6 +134,49 @@ exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
`;
|
|
137
|
+
const updateCacheRemoveFromDailyStack = (userId) => (cache, result) => {
|
|
138
|
+
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
139
|
+
const prevData = cache.readFragment({
|
|
140
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
141
|
+
fragment: fragments_1.COMPLETED_CARDS,
|
|
142
|
+
});
|
|
143
|
+
if (prevData && removeFromDailyStack && removeFromDailyStack.length) {
|
|
144
|
+
const toRemove = new Set(removeFromDailyStack.map(({ id }) => id));
|
|
145
|
+
if (toRemove.size === 0 || !userId) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const newCompletedCards = prevData.completedCards.filter(({ id }) => !toRemove.has(id));
|
|
149
|
+
cache.writeFragment({
|
|
150
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
151
|
+
data: {
|
|
152
|
+
completedCardsCount: newCompletedCards.length,
|
|
153
|
+
completedCards: newCompletedCards,
|
|
154
|
+
},
|
|
155
|
+
fragment: fragments_1.COMPLETED_CARDS,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
exports.updateCacheRemoveFromDailyStack = updateCacheRemoveFromDailyStack;
|
|
160
|
+
const updateCacheAddToDailyStack = (userId) => (cache, result) => {
|
|
161
|
+
const { addToDailyStack } = result.data?.restricted || {};
|
|
162
|
+
const prevData = cache.readFragment({
|
|
163
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
164
|
+
fragment: fragments_1.COMPLETED_CARDS,
|
|
165
|
+
});
|
|
166
|
+
const { completedCards = [] } = prevData || {};
|
|
167
|
+
if (addToDailyStack) {
|
|
168
|
+
const newCompletedCards = [...completedCards, ...addToDailyStack];
|
|
169
|
+
cache.writeFragment({
|
|
170
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
171
|
+
data: {
|
|
172
|
+
completedCardsCount: newCompletedCards.length,
|
|
173
|
+
completedCards: newCompletedCards,
|
|
174
|
+
},
|
|
175
|
+
fragment: fragments_1.COMPLETED_CARDS,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
exports.updateCacheAddToDailyStack = updateCacheAddToDailyStack;
|
|
137
180
|
exports.REFRESH_DAILY_TASK = (0, client_1.gql) `
|
|
138
181
|
${fragments_1.PICTURE_FIELDS}
|
|
139
182
|
mutation RefreshDailyTask {
|
|
@@ -30,3 +30,4 @@ export declare type IRenewTokenData = RestrictedData<string, 'renewToken'>;
|
|
|
30
30
|
export declare const TOC_ACCEPT: import("@apollo/client").DocumentNode;
|
|
31
31
|
export declare type ITocAcceptVar = null;
|
|
32
32
|
export declare type ITocAcceptData = RestrictedData<string, 'tocAccept'>;
|
|
33
|
+
export declare type ICompletedCardsData = Pick<IUser, 'completedCards' | 'completedCardsCount'>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
|
+
import { PICTURE_FIELDS } from './picture';
|
|
2
3
|
export const USER_FIELDS = gql `
|
|
3
4
|
fragment UserFields on User {
|
|
4
5
|
id
|
|
@@ -31,3 +32,41 @@ export const USER_FIELDS = gql `
|
|
|
31
32
|
# completedRedCardsCount
|
|
32
33
|
}
|
|
33
34
|
`;
|
|
35
|
+
export const COMPLETED_CARDS = gql `
|
|
36
|
+
${PICTURE_FIELDS}
|
|
37
|
+
fragment UserCompletedCards on User {
|
|
38
|
+
completedCards {
|
|
39
|
+
id
|
|
40
|
+
createdAt
|
|
41
|
+
updatedAt
|
|
42
|
+
concept {
|
|
43
|
+
id
|
|
44
|
+
name
|
|
45
|
+
}
|
|
46
|
+
lastSeen
|
|
47
|
+
reviewDate
|
|
48
|
+
score
|
|
49
|
+
iteration
|
|
50
|
+
optimalFactor
|
|
51
|
+
cardId
|
|
52
|
+
card {
|
|
53
|
+
id
|
|
54
|
+
conceptId
|
|
55
|
+
concept {
|
|
56
|
+
id
|
|
57
|
+
name
|
|
58
|
+
}
|
|
59
|
+
topic {
|
|
60
|
+
id
|
|
61
|
+
name
|
|
62
|
+
}
|
|
63
|
+
question
|
|
64
|
+
explanation
|
|
65
|
+
pictures {
|
|
66
|
+
...PictureFields
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
completedCardsCount
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
@@ -73,6 +73,9 @@ export interface IRemoveFlaggedQuestionVar {
|
|
|
73
73
|
questionId: Id;
|
|
74
74
|
}
|
|
75
75
|
export declare type IRemoveFlaggedQuestionData = RestrictedData<(graphqlNormalize & IUserFlaggedQuestion)[], 'removeFlaggedQuestion'>;
|
|
76
|
+
export declare const MARK_FLAGGED_FIELD: import("@apollo/client").DocumentNode;
|
|
77
|
+
export declare const updateCacheAddFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddFlaggedQuestionData>) => void;
|
|
78
|
+
export declare const updateCacheRemoveFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFlaggedQuestionData>) => void;
|
|
76
79
|
/**
|
|
77
80
|
* startOrJoinMarksheet
|
|
78
81
|
*/
|
|
@@ -1135,14 +1135,29 @@ export const RE_BUILD_MARKSHEET = gql `
|
|
|
1135
1135
|
restricted {
|
|
1136
1136
|
reBuildMarksheet(marksheetId: $marksheetId) {
|
|
1137
1137
|
id
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1138
|
+
topicConceptData
|
|
1139
|
+
currentMarkId
|
|
1140
|
+
completed
|
|
1141
|
+
timeTaken
|
|
1141
1142
|
topicIds
|
|
1142
1143
|
topicNames
|
|
1144
|
+
mockTestId
|
|
1145
|
+
totalQuestions
|
|
1146
|
+
solo
|
|
1147
|
+
agoraId
|
|
1143
1148
|
state
|
|
1144
|
-
|
|
1145
|
-
|
|
1149
|
+
user {
|
|
1150
|
+
id
|
|
1151
|
+
displayName
|
|
1152
|
+
}
|
|
1153
|
+
users {
|
|
1154
|
+
id
|
|
1155
|
+
displayName
|
|
1156
|
+
}
|
|
1157
|
+
activeUsers {
|
|
1158
|
+
id
|
|
1159
|
+
displayName
|
|
1160
|
+
}
|
|
1146
1161
|
builderConfig {
|
|
1147
1162
|
difficulty
|
|
1148
1163
|
isTest
|
|
@@ -1158,19 +1173,13 @@ export const RE_BUILD_MARKSHEET = gql `
|
|
|
1158
1173
|
seenIncorrect
|
|
1159
1174
|
unseen
|
|
1160
1175
|
}
|
|
1176
|
+
createdAt
|
|
1177
|
+
startedAt
|
|
1178
|
+
endedAt
|
|
1179
|
+
isTestMarksheet
|
|
1161
1180
|
source
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
displayName
|
|
1165
|
-
}
|
|
1166
|
-
users {
|
|
1167
|
-
id
|
|
1168
|
-
displayName
|
|
1169
|
-
}
|
|
1170
|
-
user {
|
|
1171
|
-
displayName
|
|
1172
|
-
id
|
|
1173
|
-
}
|
|
1181
|
+
correct
|
|
1182
|
+
incorrect
|
|
1174
1183
|
marks {
|
|
1175
1184
|
id
|
|
1176
1185
|
flagged
|
|
@@ -1680,11 +1689,6 @@ export const RE_BUILD_MARKSHEET = gql `
|
|
|
1680
1689
|
}
|
|
1681
1690
|
}
|
|
1682
1691
|
}
|
|
1683
|
-
mockTestId
|
|
1684
|
-
correct
|
|
1685
|
-
incorrect
|
|
1686
|
-
totalQuestions
|
|
1687
|
-
isTestMarksheet
|
|
1688
1692
|
}
|
|
1689
1693
|
}
|
|
1690
1694
|
}
|
|
@@ -1812,6 +1816,40 @@ export const REMOVE_FLAGGED_QUESTION = gql `
|
|
|
1812
1816
|
}
|
|
1813
1817
|
}
|
|
1814
1818
|
`;
|
|
1819
|
+
export const MARK_FLAGGED_FIELD = gql `
|
|
1820
|
+
fragment MarksheetMarkFlagged on MarksheetMark {
|
|
1821
|
+
flagged
|
|
1822
|
+
}
|
|
1823
|
+
`;
|
|
1824
|
+
export const updateCacheAddFlaggedQuestion = (cache, result) => {
|
|
1825
|
+
const { addFlaggedQuestion } = result?.data?.restricted || {};
|
|
1826
|
+
if (!addFlaggedQuestion) {
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
const { markId } = addFlaggedQuestion;
|
|
1830
|
+
cache.writeFragment({
|
|
1831
|
+
id: cache.identify({ id: markId, __typename: 'MarksheetMark' }),
|
|
1832
|
+
data: {
|
|
1833
|
+
flagged: true,
|
|
1834
|
+
},
|
|
1835
|
+
fragment: MARK_FLAGGED_FIELD,
|
|
1836
|
+
});
|
|
1837
|
+
};
|
|
1838
|
+
export const updateCacheRemoveFlaggedQuestion = (cache, result) => {
|
|
1839
|
+
const { removeFlaggedQuestion } = result?.data?.restricted || {};
|
|
1840
|
+
if (!removeFlaggedQuestion) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
removeFlaggedQuestion.forEach(({ markId }) => {
|
|
1844
|
+
cache.writeFragment({
|
|
1845
|
+
id: cache.identify({ id: Number(markId), __typename: 'MarksheetMark' }),
|
|
1846
|
+
data: {
|
|
1847
|
+
flagged: false,
|
|
1848
|
+
},
|
|
1849
|
+
fragment: MARK_FLAGGED_FIELD,
|
|
1850
|
+
});
|
|
1851
|
+
});
|
|
1852
|
+
};
|
|
1815
1853
|
export const START_OR_JOIN_MARKSHEET = gql `
|
|
1816
1854
|
mutation StartOrJoinMarksheet($agoraId: String!, $solo: Boolean!) {
|
|
1817
1855
|
restricted {
|
|
@@ -37,6 +37,8 @@ export interface IRemoveFromDailyStackVar {
|
|
|
37
37
|
conceptId?: Id;
|
|
38
38
|
}
|
|
39
39
|
export declare type IRemoveFromDailyStackData = RestrictedData<(graphqlNormalize & IUserCompletedCard)[], 'removeFromDailyStack'>;
|
|
40
|
+
export declare const updateCacheRemoveFromDailyStack: (userId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>) => void;
|
|
41
|
+
export declare const updateCacheAddToDailyStack: (userId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
40
42
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
41
43
|
export declare type IRefreshDailyTaskVar = null;
|
|
42
44
|
export declare type IRefreshDailyTaskData = RestrictedData<graphqlNormalize & ITodo, 'refreshDailyTask'>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
|
-
import { PICTURE_FIELDS } from '../../fragments';
|
|
2
|
+
import { COMPLETED_CARDS, PICTURE_FIELDS } from '../../fragments';
|
|
3
3
|
export const BUILD_TODO = gql `
|
|
4
4
|
mutation BuildTodo($buildTodo: BuildTodoInput!) {
|
|
5
5
|
restricted {
|
|
@@ -130,6 +130,47 @@ export const REMOVE_FROM_DAILY_STACK = gql `
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
`;
|
|
133
|
+
export const updateCacheRemoveFromDailyStack = (userId) => (cache, result) => {
|
|
134
|
+
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
135
|
+
const prevData = cache.readFragment({
|
|
136
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
137
|
+
fragment: COMPLETED_CARDS,
|
|
138
|
+
});
|
|
139
|
+
if (prevData && removeFromDailyStack && removeFromDailyStack.length) {
|
|
140
|
+
const toRemove = new Set(removeFromDailyStack.map(({ id }) => id));
|
|
141
|
+
if (toRemove.size === 0 || !userId) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const newCompletedCards = prevData.completedCards.filter(({ id }) => !toRemove.has(id));
|
|
145
|
+
cache.writeFragment({
|
|
146
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
147
|
+
data: {
|
|
148
|
+
completedCardsCount: newCompletedCards.length,
|
|
149
|
+
completedCards: newCompletedCards,
|
|
150
|
+
},
|
|
151
|
+
fragment: COMPLETED_CARDS,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
export const updateCacheAddToDailyStack = (userId) => (cache, result) => {
|
|
156
|
+
const { addToDailyStack } = result.data?.restricted || {};
|
|
157
|
+
const prevData = cache.readFragment({
|
|
158
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
159
|
+
fragment: COMPLETED_CARDS,
|
|
160
|
+
});
|
|
161
|
+
const { completedCards = [] } = prevData || {};
|
|
162
|
+
if (addToDailyStack) {
|
|
163
|
+
const newCompletedCards = [...completedCards, ...addToDailyStack];
|
|
164
|
+
cache.writeFragment({
|
|
165
|
+
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
166
|
+
data: {
|
|
167
|
+
completedCardsCount: newCompletedCards.length,
|
|
168
|
+
completedCards: newCompletedCards,
|
|
169
|
+
},
|
|
170
|
+
fragment: COMPLETED_CARDS,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
133
174
|
export const REFRESH_DAILY_TASK = gql `
|
|
134
175
|
${PICTURE_FIELDS}
|
|
135
176
|
mutation RefreshDailyTask {
|
|
@@ -30,3 +30,4 @@ export declare type IRenewTokenData = RestrictedData<string, 'renewToken'>;
|
|
|
30
30
|
export declare const TOC_ACCEPT: import("@apollo/client").DocumentNode;
|
|
31
31
|
export declare type ITocAcceptVar = null;
|
|
32
32
|
export declare type ITocAcceptData = RestrictedData<string, 'tocAccept'>;
|
|
33
|
+
export declare type ICompletedCardsData = Pick<IUser, 'completedCards' | 'completedCardsCount'>;
|