@magmamath/students-features 0.2.0 → 0.2.1
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/commonjs/features/chatbot/components/ChatControls/ChatControls.js +21 -5
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/commonjs/features/feedback/components/EmptyComment/EmptyComment.js +2 -2
- package/dist/commonjs/features/feedback/components/EmptyComment/EmptyComment.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedback.js +12 -5
- package/dist/commonjs/features/feedback/components/TeacherFeedback.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +65 -16
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.js +17 -0
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +7 -3
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +16 -5
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
- package/dist/commonjs/features/feedback/components/UnreadMessagesBadge.js +3 -2
- package/dist/commonjs/features/feedback/components/UnreadMessagesBadge.js.map +1 -1
- package/dist/commonjs/features/feedback/constants.js +24 -5
- package/dist/commonjs/features/feedback/constants.js.map +1 -1
- package/dist/commonjs/features/feedback/index.js +11 -0
- package/dist/commonjs/features/feedback/index.js.map +1 -1
- package/dist/commonjs/features/feedback/model/teacherFeedback.model.js +97 -34
- package/dist/commonjs/features/feedback/model/teacherFeedback.model.js.map +1 -1
- package/dist/commonjs/features/feedback/types/teacherFeedback.types.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +22 -6
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/module/features/feedback/components/EmptyComment/EmptyComment.js +3 -3
- package/dist/module/features/feedback/components/EmptyComment/EmptyComment.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedback.js +12 -5
- package/dist/module/features/feedback/components/TeacherFeedback.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +65 -16
- package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.js +17 -0
- package/dist/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +8 -4
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +17 -6
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
- package/dist/module/features/feedback/components/UnreadMessagesBadge.js +3 -2
- package/dist/module/features/feedback/components/UnreadMessagesBadge.js.map +1 -1
- package/dist/module/features/feedback/constants.js +23 -4
- package/dist/module/features/feedback/constants.js.map +1 -1
- package/dist/module/features/feedback/index.js +1 -0
- package/dist/module/features/feedback/index.js.map +1 -1
- package/dist/module/features/feedback/model/teacherFeedback.model.js +97 -34
- package/dist/module/features/feedback/model/teacherFeedback.model.js.map +1 -1
- package/dist/module/features/feedback/types/teacherFeedback.types.js.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts +4 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts +4 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts +17 -0
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts +3 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/UnreadMessagesBadge.d.ts +3 -2
- package/dist/typescript/commonjs/features/feedback/components/UnreadMessagesBadge.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/constants.d.ts +15 -3
- package/dist/typescript/commonjs/features/feedback/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/index.d.ts +1 -0
- package/dist/typescript/commonjs/features/feedback/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/model/teacherFeedback.model.d.ts +6 -5
- package/dist/typescript/commonjs/features/feedback/model/teacherFeedback.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/types/teacherFeedback.types.d.ts +6 -0
- package/dist/typescript/commonjs/features/feedback/types/teacherFeedback.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts +4 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts +4 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts +17 -0
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts +3 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/UnreadMessagesBadge.d.ts +3 -2
- package/dist/typescript/module/features/feedback/components/UnreadMessagesBadge.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/constants.d.ts +15 -3
- package/dist/typescript/module/features/feedback/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/index.d.ts +1 -0
- package/dist/typescript/module/features/feedback/index.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/model/teacherFeedback.model.d.ts +6 -5
- package/dist/typescript/module/features/feedback/model/teacherFeedback.model.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/types/teacherFeedback.types.d.ts +6 -0
- package/dist/typescript/module/features/feedback/types/teacherFeedback.types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +27 -4
- package/src/features/feedback/components/EmptyComment/EmptyComment.tsx +3 -3
- package/src/features/feedback/components/TeacherFeedback.tsx +10 -4
- package/src/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.tsx +71 -13
- package/src/features/feedback/components/TeacherFeedbackButton/colorSchemes.ts +17 -0
- package/src/features/feedback/components/TeacherFeedbackComments/TeacherComment.tsx +6 -5
- package/src/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.tsx +24 -4
- package/src/features/feedback/components/UnreadMessagesBadge.tsx +4 -3
- package/src/features/feedback/constants.ts +25 -5
- package/src/features/feedback/index.ts +1 -0
- package/src/features/feedback/model/teacherFeedback.model.ts +125 -47
- package/src/features/feedback/types/teacherFeedback.types.ts +5 -0
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createEffect,
|
|
3
|
+
createEvent,
|
|
4
|
+
createStore,
|
|
5
|
+
Effect,
|
|
6
|
+
restore,
|
|
7
|
+
sample,
|
|
8
|
+
StoreWritable,
|
|
9
|
+
} from 'effector'
|
|
2
10
|
import {
|
|
3
11
|
CommentsEntity,
|
|
4
12
|
GetCommentsByIdProps,
|
|
13
|
+
GetCommentsByIdResponse,
|
|
5
14
|
Locale,
|
|
6
15
|
TeacherComment,
|
|
7
16
|
UpdateCommentSeenStatusProps,
|
|
@@ -10,28 +19,32 @@ import { EMPTY_COMMENT_ID, getEmptyComment } from '../constants'
|
|
|
10
19
|
|
|
11
20
|
type TeacherFeedbackModelProps = {
|
|
12
21
|
credits: {
|
|
22
|
+
assignmentId: StoreWritable<string>
|
|
13
23
|
problemId: StoreWritable<string>
|
|
14
24
|
locale: StoreWritable<Locale | null>
|
|
15
25
|
}
|
|
16
26
|
api: {
|
|
17
|
-
getCommentsByAssignmentId: (
|
|
27
|
+
getCommentsByAssignmentId: (
|
|
28
|
+
props: GetCommentsByIdProps,
|
|
29
|
+
) => Promise<Record<string, { comments: TeacherComment[] }>>
|
|
18
30
|
updateCommentSeenStatus: (props: UpdateCommentSeenStatusProps) => Promise<void>
|
|
19
31
|
}
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
export class TeacherFeedbackModel {
|
|
35
|
+
$assignmentId: StoreWritable<string>
|
|
23
36
|
$currentProblemId: StoreWritable<string>
|
|
24
37
|
$locale: StoreWritable<Locale | null>
|
|
25
38
|
|
|
26
|
-
setCommentsSeen = createEvent<{ ids: string[]; currentProblemId: string }>()
|
|
27
|
-
$comments = createStore<Map<string, CommentsEntity
|
|
39
|
+
setCommentsSeen = createEvent<{ ids: string[]; currentProblemId: string; assignmentId: string }>()
|
|
40
|
+
$comments = createStore<Map<string, Record<string, CommentsEntity>>>(new Map())
|
|
28
41
|
|
|
29
42
|
setIsOpened = createEvent<boolean>()
|
|
30
43
|
$isOpened = restore(this.setIsOpened, false)
|
|
31
44
|
setIsVisible = createEvent<boolean>()
|
|
32
45
|
$isVisible = restore(this.setIsVisible, false)
|
|
33
46
|
|
|
34
|
-
getCommentsByAssignmentIdFx: Effect<GetCommentsByIdProps,
|
|
47
|
+
getCommentsByAssignmentIdFx: Effect<GetCommentsByIdProps, GetCommentsByIdResponse>
|
|
35
48
|
updateCommentSeenFx: Effect<UpdateCommentSeenStatusProps, void>
|
|
36
49
|
|
|
37
50
|
sockets = {
|
|
@@ -40,8 +53,15 @@ export class TeacherFeedbackModel {
|
|
|
40
53
|
}
|
|
41
54
|
|
|
42
55
|
constructor({ api, credits }: TeacherFeedbackModelProps) {
|
|
43
|
-
this.getCommentsByAssignmentIdFx = createEffect(
|
|
56
|
+
this.getCommentsByAssignmentIdFx = createEffect(async ({ id }: GetCommentsByIdProps) => {
|
|
57
|
+
const response = await api.getCommentsByAssignmentId({ id })
|
|
58
|
+
return {
|
|
59
|
+
data: response,
|
|
60
|
+
assignmentId: id,
|
|
61
|
+
}
|
|
62
|
+
})
|
|
44
63
|
this.updateCommentSeenFx = createEffect(api.updateCommentSeenStatus)
|
|
64
|
+
this.$assignmentId = credits.assignmentId
|
|
45
65
|
this.$currentProblemId = credits.problemId
|
|
46
66
|
this.$locale = credits.locale
|
|
47
67
|
|
|
@@ -53,10 +73,13 @@ export class TeacherFeedbackModel {
|
|
|
53
73
|
|
|
54
74
|
sample({
|
|
55
75
|
clock: this.sockets.onCreate,
|
|
56
|
-
source: [this.$isOpened, this.$currentProblemId] as const,
|
|
57
|
-
filter: ([isOpen]) =>
|
|
58
|
-
|
|
76
|
+
source: [this.$isOpened, this.$currentProblemId, this.$assignmentId] as const,
|
|
77
|
+
filter: ([isOpen, currentProblemId], payload) => {
|
|
78
|
+
return isOpen && currentProblemId === payload.problemId
|
|
79
|
+
},
|
|
80
|
+
fn: ([_, currentProblemId, assignmentId], { _id }) => ({
|
|
59
81
|
currentProblemId,
|
|
82
|
+
assignmentId,
|
|
60
83
|
ids: [_id],
|
|
61
84
|
}),
|
|
62
85
|
target: [this.setCommentsSeen, this.updateCommentSeenFx],
|
|
@@ -64,46 +87,54 @@ export class TeacherFeedbackModel {
|
|
|
64
87
|
|
|
65
88
|
sample({
|
|
66
89
|
clock: this.$isOpened,
|
|
67
|
-
source: [this.$comments, this.$currentProblemId] as const,
|
|
68
|
-
filter: ([feedback, currentProblemId], isOpen) => {
|
|
69
|
-
const
|
|
70
|
-
const
|
|
90
|
+
source: [this.$comments, this.$currentProblemId, this.$assignmentId] as const,
|
|
91
|
+
filter: ([feedback, currentProblemId, assignmentId], isOpen) => {
|
|
92
|
+
const assignmentComments = feedback.get(assignmentId) || {}
|
|
93
|
+
const comments = assignmentComments[currentProblemId]?.comments ?? []
|
|
94
|
+
const hasUnreadComments = comments.some(comment => !comment.isRead)
|
|
71
95
|
return isOpen && hasUnreadComments
|
|
72
96
|
},
|
|
73
|
-
fn: ([feedback, currentProblemId]) => {
|
|
74
|
-
const
|
|
97
|
+
fn: ([feedback, currentProblemId, assignmentId]) => {
|
|
98
|
+
const assignmentComments = feedback.get(assignmentId) || {}
|
|
99
|
+
const comments = assignmentComments[currentProblemId]?.comments ?? []
|
|
75
100
|
return {
|
|
76
101
|
currentProblemId,
|
|
77
|
-
|
|
102
|
+
assignmentId,
|
|
103
|
+
ids: comments.filter(comment => !comment.isRead).map(comment => comment._id),
|
|
78
104
|
}
|
|
79
105
|
},
|
|
80
106
|
target: [this.setCommentsSeen, this.updateCommentSeenFx],
|
|
81
107
|
})
|
|
82
108
|
|
|
83
|
-
this.$isVisible.on(this.getCommentsByAssignmentIdFx.doneData, (_,
|
|
84
|
-
return Object.values(
|
|
109
|
+
this.$isVisible.on(this.getCommentsByAssignmentIdFx.doneData, (_, { data }) => {
|
|
110
|
+
return Object.values(data).some(problemFeedback => problemFeedback.comments?.length > 0)
|
|
85
111
|
})
|
|
86
112
|
|
|
87
113
|
this.$comments
|
|
88
|
-
.on(this.getCommentsByAssignmentIdFx.doneData, (
|
|
89
|
-
const
|
|
114
|
+
.on(this.getCommentsByAssignmentIdFx.doneData, (state, { assignmentId, data }) => {
|
|
115
|
+
const problemsMap: Record<string, CommentsEntity> = {}
|
|
90
116
|
|
|
91
|
-
for (const [problemId, { comments }] of Object.entries(
|
|
92
|
-
const unreadMessages = comments.filter(
|
|
93
|
-
|
|
117
|
+
for (const [problemId, { comments }] of Object.entries(data)) {
|
|
118
|
+
const unreadMessages = comments.filter(comment => !comment.isRead)
|
|
119
|
+
problemsMap[problemId] = {
|
|
94
120
|
comments,
|
|
95
121
|
unreadMessagesCount: unreadMessages.length,
|
|
96
|
-
}
|
|
122
|
+
}
|
|
97
123
|
}
|
|
98
124
|
|
|
99
|
-
|
|
125
|
+
const updatedState = new Map(state)
|
|
126
|
+
updatedState.set(assignmentId, problemsMap)
|
|
127
|
+
return updatedState
|
|
100
128
|
})
|
|
101
|
-
.on(this.setCommentsSeen, (state, { ids, currentProblemId }) => {
|
|
102
|
-
const
|
|
129
|
+
.on(this.setCommentsSeen, (state, { ids, currentProblemId, assignmentId }) => {
|
|
130
|
+
const assignmentComments = state.get(assignmentId)
|
|
131
|
+
if (!assignmentComments) return state
|
|
132
|
+
|
|
133
|
+
const feedback = assignmentComments[currentProblemId]
|
|
103
134
|
if (!feedback) return state
|
|
104
135
|
|
|
105
|
-
const updatedComments = feedback.comments.map(
|
|
106
|
-
ids.includes(comment._id) ? { ...comment, isRead: true } : comment
|
|
136
|
+
const updatedComments = feedback.comments.map(comment =>
|
|
137
|
+
ids.includes(comment._id) ? { ...comment, isRead: true } : comment,
|
|
107
138
|
)
|
|
108
139
|
|
|
109
140
|
const updatedFeedback = {
|
|
@@ -112,13 +143,22 @@ export class TeacherFeedbackModel {
|
|
|
112
143
|
unreadMessagesCount: 0,
|
|
113
144
|
}
|
|
114
145
|
|
|
146
|
+
const updatedAssignmentComments = {
|
|
147
|
+
...assignmentComments,
|
|
148
|
+
[currentProblemId]: updatedFeedback,
|
|
149
|
+
}
|
|
150
|
+
|
|
115
151
|
const updatedState = new Map(state)
|
|
116
|
-
updatedState.set(
|
|
152
|
+
updatedState.set(assignmentId, updatedAssignmentComments)
|
|
117
153
|
|
|
118
154
|
return updatedState
|
|
119
155
|
})
|
|
120
156
|
.on(this.sockets.onCreate, (state, payload) => {
|
|
121
|
-
const
|
|
157
|
+
const assignmentComments = state.get(payload.exerciseId) || {}
|
|
158
|
+
const feedback = assignmentComments[payload.problemId] ?? {
|
|
159
|
+
comments: [],
|
|
160
|
+
unreadMessagesCount: 0,
|
|
161
|
+
}
|
|
122
162
|
|
|
123
163
|
const updatedFeedback = {
|
|
124
164
|
...feedback,
|
|
@@ -126,53 +166,91 @@ export class TeacherFeedbackModel {
|
|
|
126
166
|
unreadMessagesCount: feedback.unreadMessagesCount + 1,
|
|
127
167
|
}
|
|
128
168
|
|
|
169
|
+
const updatedAssignmentComments = {
|
|
170
|
+
...assignmentComments,
|
|
171
|
+
[payload.problemId]: updatedFeedback,
|
|
172
|
+
}
|
|
173
|
+
|
|
129
174
|
const updatedState = new Map(state)
|
|
130
|
-
updatedState.set(payload.
|
|
175
|
+
updatedState.set(payload.exerciseId, updatedAssignmentComments)
|
|
131
176
|
|
|
132
177
|
return updatedState
|
|
133
178
|
})
|
|
134
179
|
.on(this.sockets.onDeleted, (state, payload) => {
|
|
135
|
-
const
|
|
180
|
+
const assignmentId = this.$assignmentId.getState()
|
|
181
|
+
const assignmentComments = state.get(assignmentId)
|
|
182
|
+
if (!assignmentComments) return state
|
|
183
|
+
|
|
184
|
+
const feedback = assignmentComments[payload.problemId]
|
|
136
185
|
if (!feedback) return state
|
|
137
186
|
|
|
138
187
|
const isDeleteMessageUnread = feedback.comments.some(
|
|
139
|
-
|
|
188
|
+
comment => comment._id === payload._id && !comment.isRead,
|
|
140
189
|
)
|
|
141
190
|
|
|
142
191
|
const updatedFeedback = {
|
|
143
|
-
comments: feedback.comments.filter(
|
|
144
|
-
unreadMessagesCount: isDeleteMessageUnread
|
|
192
|
+
comments: feedback.comments.filter(comment => comment._id !== payload._id),
|
|
193
|
+
unreadMessagesCount: isDeleteMessageUnread
|
|
194
|
+
? feedback.unreadMessagesCount - 1
|
|
195
|
+
: feedback.unreadMessagesCount,
|
|
145
196
|
}
|
|
146
197
|
|
|
147
|
-
const updatedState = new Map(state)
|
|
148
|
-
const isOpen = this.$isOpened.getState()
|
|
149
|
-
|
|
150
198
|
if (updatedFeedback.comments.length === 0) {
|
|
199
|
+
const updatedAssignmentComments = { ...assignmentComments }
|
|
200
|
+
const isOpen = this.$isOpened.getState()
|
|
201
|
+
|
|
151
202
|
if (!isOpen) {
|
|
152
|
-
|
|
153
|
-
|
|
203
|
+
delete updatedAssignmentComments[payload.problemId]
|
|
204
|
+
|
|
205
|
+
if (Object.keys(updatedAssignmentComments).length === 0) {
|
|
206
|
+
const updatedState = new Map(state)
|
|
207
|
+
updatedState.delete(assignmentId)
|
|
208
|
+
return updatedState
|
|
209
|
+
}
|
|
154
210
|
}
|
|
155
211
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
212
|
+
updatedAssignmentComments[payload.problemId] = {
|
|
213
|
+
...updatedFeedback,
|
|
214
|
+
comments: [getEmptyComment(payload.problemId, this.$locale.getState())],
|
|
215
|
+
}
|
|
159
216
|
|
|
217
|
+
const updatedState = new Map(state)
|
|
218
|
+
updatedState.set(assignmentId, updatedAssignmentComments)
|
|
160
219
|
return updatedState
|
|
161
220
|
}
|
|
162
221
|
|
|
163
|
-
|
|
222
|
+
const updatedAssignmentComments = {
|
|
223
|
+
...assignmentComments,
|
|
224
|
+
[payload.problemId]: updatedFeedback,
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const updatedState = new Map(state)
|
|
228
|
+
updatedState.set(assignmentId, updatedAssignmentComments)
|
|
164
229
|
return updatedState
|
|
165
230
|
})
|
|
166
231
|
.on(this.setIsOpened, (state, isOpen) => {
|
|
167
232
|
if (isOpen) return state
|
|
168
233
|
|
|
234
|
+
const assignmentId = this.$assignmentId.getState()
|
|
169
235
|
const problemId = this.$currentProblemId.getState()
|
|
170
|
-
const
|
|
236
|
+
const assignmentComments = state.get(assignmentId)
|
|
237
|
+
if (!assignmentComments) return state
|
|
238
|
+
|
|
239
|
+
const feedback = assignmentComments[problemId]
|
|
171
240
|
if (!feedback) return state
|
|
172
241
|
|
|
173
242
|
if (feedback.comments.length === 1 && feedback.comments[0]._id === EMPTY_COMMENT_ID) {
|
|
243
|
+
const updatedAssignmentComments = { ...assignmentComments }
|
|
244
|
+
delete updatedAssignmentComments[problemId]
|
|
245
|
+
|
|
246
|
+
if (Object.keys(updatedAssignmentComments).length === 0) {
|
|
247
|
+
const updatedState = new Map(state)
|
|
248
|
+
updatedState.delete(assignmentId)
|
|
249
|
+
return updatedState
|
|
250
|
+
}
|
|
251
|
+
|
|
174
252
|
const updatedState = new Map(state)
|
|
175
|
-
updatedState.
|
|
253
|
+
updatedState.set(assignmentId, updatedAssignmentComments)
|
|
176
254
|
return updatedState
|
|
177
255
|
}
|
|
178
256
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export type GetCommentsByIdProps = { id: string }
|
|
2
|
+
export type GetCommentsByIdResponse = {
|
|
3
|
+
data: Record<string, { comments: TeacherComment[] }>
|
|
4
|
+
assignmentId: string
|
|
5
|
+
}
|
|
6
|
+
|
|
2
7
|
export type UpdateCommentSeenStatusProps = { ids: string[] }
|
|
3
8
|
|
|
4
9
|
export type TeacherComment = {
|