@quesmed/types-rn 2.4.6 → 2.4.8
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/models/User.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.currentClassGroup = exports.currentClassYear = exports.EPracticeIntensity = exports.classYearGroup = exports.EClassYearGroup = exports.classYears = void 0;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
4
5
|
exports.classYears = [
|
|
5
6
|
'Year 1',
|
|
6
7
|
'Year 2',
|
|
@@ -33,7 +34,7 @@ var EPracticeIntensity;
|
|
|
33
34
|
EPracticeIntensity[EPracticeIntensity["MED"] = 2] = "MED";
|
|
34
35
|
EPracticeIntensity[EPracticeIntensity["HIGH"] = 3] = "HIGH";
|
|
35
36
|
})(EPracticeIntensity = exports.EPracticeIntensity || (exports.EPracticeIntensity = {}));
|
|
36
|
-
function currentClassYear(createdAtUnix, classYear, compareUnix =
|
|
37
|
+
function currentClassYear(createdAtUnix, classYear, compareUnix = luxon_1.DateTime.now().toUnixInteger()) {
|
|
37
38
|
if (createdAtUnix === 0) {
|
|
38
39
|
throw new Error('createdAt not given in Unix');
|
|
39
40
|
}
|
|
@@ -45,20 +46,18 @@ function currentClassYear(createdAtUnix, classYear, compareUnix = new Date().get
|
|
|
45
46
|
if (classYearsIdx === -1) {
|
|
46
47
|
return exports.classYears[lastClassYearIdx];
|
|
47
48
|
}
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
if (createdAt.getFullYear() > compareDate.getFullYear()) {
|
|
49
|
+
const compareDT = luxon_1.DateTime.fromSeconds(compareUnix);
|
|
50
|
+
const createdAtDT = luxon_1.DateTime.fromSeconds(createdAtUnix);
|
|
51
|
+
if (createdAtDT.year > compareDT.year) {
|
|
52
52
|
throw new Error('createdAt not given in Unix');
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (createdAt > createdAcademicYear) {
|
|
59
|
-
yearsAdded--;
|
|
54
|
+
let yearsAdded = compareDT.year - createdAtDT.year;
|
|
55
|
+
let createdAtAcademicDT = luxon_1.DateTime.local(createdAtDT.year, 8, 1);
|
|
56
|
+
if (createdAtDT < createdAtAcademicDT) {
|
|
57
|
+
createdAtAcademicDT = createdAtAcademicDT.minus({ year: 1 });
|
|
60
58
|
}
|
|
61
|
-
|
|
59
|
+
const compareAcademicDT = luxon_1.DateTime.local(compareDT.year, 8, 1);
|
|
60
|
+
if (compareDT > compareAcademicDT) {
|
|
62
61
|
yearsAdded++;
|
|
63
62
|
}
|
|
64
63
|
const newClassYearIdx = classYearsIdx + yearsAdded;
|
package/package.json
CHANGED
|
@@ -31,14 +31,20 @@ export declare const ADD_TO_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
|
31
31
|
export interface IAddToDailyStackVar {
|
|
32
32
|
conceptIds: Id[];
|
|
33
33
|
}
|
|
34
|
-
export declare type IAddToDailyStackData = RestrictedData<
|
|
34
|
+
export declare type IAddToDailyStackData = RestrictedData<graphqlNormalize & {
|
|
35
|
+
addedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
|
|
36
|
+
dailyFeed: graphqlNormalize & ITodo;
|
|
37
|
+
}, 'addToDailyStack'>;
|
|
35
38
|
export declare const REMOVE_FROM_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
36
39
|
export interface IRemoveFromDailyStackVar {
|
|
37
40
|
cardId?: Id;
|
|
38
41
|
todoId?: Id;
|
|
39
42
|
conceptId?: Id;
|
|
40
43
|
}
|
|
41
|
-
export declare type IRemoveFromDailyStackData = RestrictedData<
|
|
44
|
+
export declare type IRemoveFromDailyStackData = RestrictedData<graphqlNormalize & {
|
|
45
|
+
removedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
|
|
46
|
+
dailyFeed: graphqlNormalize & ITodo;
|
|
47
|
+
}, 'removeFromDailyStack'>;
|
|
42
48
|
export declare const updateCacheOnRemoveFromDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>, options: ApolloUpdateOptions) => void;
|
|
43
49
|
export declare const updateCacheOnAddToDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
44
50
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
@@ -118,34 +118,42 @@ exports.ADD_TO_DAILY_STACK = (0, client_1.gql) `
|
|
|
118
118
|
mutation AddToDailyStack($conceptIds: [Int!]!) {
|
|
119
119
|
restricted {
|
|
120
120
|
addToDailyStack(conceptIds: $conceptIds) {
|
|
121
|
-
|
|
122
|
-
createdAt
|
|
123
|
-
updatedAt
|
|
124
|
-
concept {
|
|
125
|
-
id
|
|
126
|
-
name
|
|
127
|
-
}
|
|
128
|
-
lastSeen
|
|
129
|
-
reviewDate
|
|
130
|
-
score
|
|
131
|
-
iteration
|
|
132
|
-
optimalFactor
|
|
133
|
-
cardId
|
|
134
|
-
card {
|
|
121
|
+
addedUserCompletedCards {
|
|
135
122
|
id
|
|
136
|
-
|
|
123
|
+
createdAt
|
|
124
|
+
updatedAt
|
|
137
125
|
concept {
|
|
138
126
|
id
|
|
139
127
|
name
|
|
140
128
|
}
|
|
141
|
-
|
|
129
|
+
lastSeen
|
|
130
|
+
reviewDate
|
|
131
|
+
score
|
|
132
|
+
iteration
|
|
133
|
+
optimalFactor
|
|
134
|
+
cardId
|
|
135
|
+
card {
|
|
142
136
|
id
|
|
143
|
-
|
|
137
|
+
conceptId
|
|
138
|
+
concept {
|
|
139
|
+
id
|
|
140
|
+
name
|
|
141
|
+
}
|
|
142
|
+
topic {
|
|
143
|
+
id
|
|
144
|
+
name
|
|
145
|
+
}
|
|
146
|
+
question
|
|
147
|
+
explanation
|
|
148
|
+
pictures {
|
|
149
|
+
...PictureFields
|
|
150
|
+
}
|
|
144
151
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
}
|
|
153
|
+
dailyFeed {
|
|
154
|
+
id
|
|
155
|
+
marks {
|
|
156
|
+
id
|
|
149
157
|
}
|
|
150
158
|
}
|
|
151
159
|
}
|
|
@@ -160,24 +168,32 @@ exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
|
|
|
160
168
|
todoId: $todoId
|
|
161
169
|
conceptId: $conceptId
|
|
162
170
|
) {
|
|
163
|
-
|
|
164
|
-
cardId
|
|
165
|
-
concept {
|
|
171
|
+
removedUserCompletedCards {
|
|
166
172
|
id
|
|
167
|
-
|
|
173
|
+
cardId
|
|
174
|
+
concept {
|
|
175
|
+
id
|
|
176
|
+
name
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
dailyFeed {
|
|
180
|
+
id
|
|
181
|
+
marks {
|
|
182
|
+
id
|
|
183
|
+
}
|
|
168
184
|
}
|
|
169
185
|
}
|
|
170
186
|
}
|
|
171
187
|
}
|
|
172
188
|
`;
|
|
173
189
|
const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
174
|
-
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
190
|
+
const { removeFromDailyStack: data } = result.data?.restricted || {};
|
|
175
191
|
const { variables } = options || {};
|
|
176
192
|
const { todoId } = variables || {};
|
|
177
|
-
if (!
|
|
193
|
+
if (!data || !data.removedUserCompletedCards.length) {
|
|
178
194
|
return;
|
|
179
195
|
}
|
|
180
|
-
const toRemove = new Set(
|
|
196
|
+
const toRemove = new Set(data.removedUserCompletedCards.map(({ cardId }) => cardId));
|
|
181
197
|
const prevData = cache.readQuery({
|
|
182
198
|
query: restricted_1.USER_COMPLETED_DATA,
|
|
183
199
|
});
|
|
@@ -223,14 +239,14 @@ const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
|
223
239
|
};
|
|
224
240
|
exports.updateCacheOnRemoveFromDailyStack = updateCacheOnRemoveFromDailyStack;
|
|
225
241
|
const updateCacheOnAddToDailyStack = (cache, result) => {
|
|
226
|
-
const { addToDailyStack } = result.data?.restricted || {};
|
|
242
|
+
const { addToDailyStack: data } = result.data?.restricted || {};
|
|
227
243
|
const prevData = cache.readQuery({
|
|
228
244
|
query: restricted_1.USER_COMPLETED_DATA,
|
|
229
245
|
});
|
|
230
|
-
if (prevData &&
|
|
246
|
+
if (prevData && data) {
|
|
231
247
|
const newCompletedCards = [
|
|
232
248
|
...prevData.restricted.user.completedCards,
|
|
233
|
-
...
|
|
249
|
+
...data.addedUserCompletedCards,
|
|
234
250
|
];
|
|
235
251
|
cache.writeQuery({
|
|
236
252
|
query: restricted_1.USER_COMPLETED_DATA,
|