@magmamath/students-features 0.2.3 → 0.2.5
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/feedback/assets/icons/MessageBubbleIcon.js.map +1 -0
- package/dist/commonjs/features/feedback/assets/icons/XCloseIcon.js.map +1 -0
- package/dist/commonjs/features/feedback/components/{EmptyComment/EmptyComment.js → EmptyComment.js} +3 -3
- package/dist/commonjs/features/feedback/components/EmptyComment.js.map +1 -0
- package/dist/commonjs/features/feedback/components/{ListCardCommentsCount/ListCardCommentsCount.js → ListCardCommentsCount.js} +2 -2
- package/dist/commonjs/features/feedback/components/ListCardCommentsCount.js.map +1 -0
- package/dist/commonjs/features/feedback/components/TeacherFeedback.js +8 -8
- package/dist/commonjs/features/feedback/components/TeacherFeedback.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +2 -2
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +3 -3
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
- package/dist/commonjs/features/feedback/components/index.js +1 -1
- package/dist/commonjs/features/feedback/constants.js +1 -18
- package/dist/commonjs/features/feedback/constants.js.map +1 -1
- package/dist/commonjs/features/feedback/helpers.js +22 -64
- package/dist/commonjs/features/feedback/helpers.js.map +1 -1
- package/dist/commonjs/features/feedback/index.js +8 -8
- package/dist/commonjs/features/feedback/index.js.map +1 -1
- package/dist/commonjs/features/feedback/model/api.js +15 -0
- package/dist/commonjs/features/feedback/model/api.js.map +1 -0
- package/dist/commonjs/features/feedback/model/comments.js +139 -0
- package/dist/commonjs/features/feedback/model/comments.js.map +1 -0
- package/dist/commonjs/features/feedback/model/model.js +134 -0
- package/dist/commonjs/features/feedback/model/model.js.map +1 -0
- package/dist/commonjs/features/feedback/model/sockets.js +25 -0
- package/dist/commonjs/features/feedback/model/sockets.js.map +1 -0
- package/dist/commonjs/features/feedback/types.js +12 -0
- package/dist/commonjs/features/feedback/types.js.map +1 -0
- package/dist/commonjs/lib/helpers/helpers.js +24 -1
- package/dist/commonjs/lib/helpers/helpers.js.map +1 -1
- package/dist/commonjs/shared/translation/constants.js +42 -1
- package/dist/commonjs/shared/translation/constants.js.map +1 -1
- package/dist/module/features/feedback/assets/icons/MessageBubbleIcon.js.map +1 -0
- package/dist/module/features/feedback/assets/icons/XCloseIcon.js.map +1 -0
- package/dist/module/features/feedback/components/{EmptyComment/EmptyComment.js → EmptyComment.js} +3 -3
- package/dist/module/features/feedback/components/EmptyComment.js.map +1 -0
- package/dist/module/features/feedback/components/{ListCardCommentsCount/ListCardCommentsCount.js → ListCardCommentsCount.js} +2 -2
- package/dist/module/features/feedback/components/ListCardCommentsCount.js.map +1 -0
- package/dist/module/features/feedback/components/TeacherFeedback.js +8 -8
- package/dist/module/features/feedback/components/TeacherFeedback.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +2 -2
- package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +3 -3
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
- package/dist/module/features/feedback/components/index.js +1 -1
- package/dist/module/features/feedback/components/index.js.map +1 -1
- package/dist/module/features/feedback/constants.js +0 -16
- package/dist/module/features/feedback/constants.js.map +1 -1
- package/dist/module/features/feedback/helpers.js +20 -62
- package/dist/module/features/feedback/helpers.js.map +1 -1
- package/dist/module/features/feedback/index.js +2 -2
- package/dist/module/features/feedback/index.js.map +1 -1
- package/dist/module/features/feedback/model/api.js +10 -0
- package/dist/module/features/feedback/model/api.js.map +1 -0
- package/dist/module/features/feedback/model/comments.js +134 -0
- package/dist/module/features/feedback/model/comments.js.map +1 -0
- package/dist/module/features/feedback/model/model.js +129 -0
- package/dist/module/features/feedback/model/model.js.map +1 -0
- package/dist/module/features/feedback/model/sockets.js +20 -0
- package/dist/module/features/feedback/model/sockets.js.map +1 -0
- package/dist/module/features/feedback/types.js +8 -0
- package/dist/module/features/feedback/types.js.map +1 -0
- package/dist/module/lib/helpers/helpers.js +22 -0
- package/dist/module/lib/helpers/helpers.js.map +1 -1
- package/dist/module/shared/translation/constants.js +41 -0
- package/dist/module/shared/translation/constants.js.map +1 -1
- package/dist/typescript/commonjs/features/feedback/assets/icons/MessageBubbleIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/assets/icons/XCloseIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/components/{EmptyComment/EmptyComment.d.ts → EmptyComment.d.ts} +1 -1
- package/dist/typescript/commonjs/features/feedback/components/EmptyComment.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/components/ListCardCommentsCount.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts +6 -2
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -2
- 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 -2
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/index.d.ts +1 -1
- package/dist/typescript/commonjs/features/feedback/components/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/constants.d.ts +0 -14
- package/dist/typescript/commonjs/features/feedback/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/helpers.d.ts +9 -2
- package/dist/typescript/commonjs/features/feedback/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/index.d.ts +2 -2
- package/dist/typescript/commonjs/features/feedback/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/model/api.d.ts +9 -0
- package/dist/typescript/commonjs/features/feedback/model/api.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/model/comments.d.ts +20 -0
- package/dist/typescript/commonjs/features/feedback/model/comments.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/model/model.d.ts +28 -0
- package/dist/typescript/commonjs/features/feedback/model/model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/model/sockets.d.ts +10 -0
- package/dist/typescript/commonjs/features/feedback/model/sockets.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/types.d.ts +44 -0
- package/dist/typescript/commonjs/features/feedback/types.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/helpers/helpers.d.ts +2 -0
- package/dist/typescript/commonjs/lib/helpers/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/constants.d.ts +41 -0
- package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/assets/icons/MessageBubbleIcon.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/assets/icons/XCloseIcon.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/components/{EmptyComment/EmptyComment.d.ts → EmptyComment.d.ts} +1 -1
- package/dist/typescript/module/features/feedback/components/EmptyComment.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/components/ListCardCommentsCount.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts +6 -2
- package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -2
- 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 -2
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/index.d.ts +1 -1
- package/dist/typescript/module/features/feedback/components/index.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/constants.d.ts +0 -14
- package/dist/typescript/module/features/feedback/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/helpers.d.ts +9 -2
- package/dist/typescript/module/features/feedback/helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/index.d.ts +2 -2
- package/dist/typescript/module/features/feedback/index.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/model/api.d.ts +9 -0
- package/dist/typescript/module/features/feedback/model/api.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/model/comments.d.ts +20 -0
- package/dist/typescript/module/features/feedback/model/comments.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/model/model.d.ts +28 -0
- package/dist/typescript/module/features/feedback/model/model.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/model/sockets.d.ts +10 -0
- package/dist/typescript/module/features/feedback/model/sockets.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/types.d.ts +44 -0
- package/dist/typescript/module/features/feedback/types.d.ts.map +1 -0
- package/dist/typescript/module/lib/helpers/helpers.d.ts +2 -0
- package/dist/typescript/module/lib/helpers/helpers.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/constants.d.ts +41 -0
- package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/feedback/components/{EmptyComment/EmptyComment.tsx → EmptyComment.tsx} +3 -3
- package/src/features/feedback/components/{ListCardCommentsCount/ListCardCommentsCount.tsx → ListCardCommentsCount.tsx} +2 -2
- package/src/features/feedback/components/TeacherFeedback.tsx +21 -11
- package/src/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.tsx +2 -2
- package/src/features/feedback/components/TeacherFeedbackComments/TeacherComment.tsx +10 -4
- package/src/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.tsx +4 -3
- package/src/features/feedback/components/index.ts +1 -1
- package/src/features/feedback/constants.ts +2 -18
- package/src/features/feedback/helpers.ts +27 -60
- package/src/features/feedback/index.ts +2 -2
- package/src/features/feedback/model/api.ts +13 -0
- package/src/features/feedback/model/comments.ts +127 -0
- package/src/features/feedback/model/model.ts +125 -0
- package/src/features/feedback/model/sockets.ts +22 -0
- package/src/features/feedback/types.ts +48 -0
- package/src/lib/helpers/helpers.ts +26 -0
- package/src/shared/translation/constants.ts +45 -3
- package/dist/commonjs/features/feedback/components/EmptyComment/EmptyComment.js.map +0 -1
- package/dist/commonjs/features/feedback/components/ListCardCommentsCount/ListCardCommentsCount.js.map +0 -1
- package/dist/commonjs/features/feedback/components/icons/MessageBubbleIcon.js.map +0 -1
- package/dist/commonjs/features/feedback/components/icons/XCloseIcon.js.map +0 -1
- package/dist/commonjs/features/feedback/model/teacherFeedback.model.js +0 -211
- package/dist/commonjs/features/feedback/model/teacherFeedback.model.js.map +0 -1
- package/dist/commonjs/features/feedback/types/teacherFeedback.types.js +0 -18
- package/dist/commonjs/features/feedback/types/teacherFeedback.types.js.map +0 -1
- package/dist/module/features/feedback/components/EmptyComment/EmptyComment.js.map +0 -1
- package/dist/module/features/feedback/components/ListCardCommentsCount/ListCardCommentsCount.js.map +0 -1
- package/dist/module/features/feedback/components/icons/MessageBubbleIcon.js.map +0 -1
- package/dist/module/features/feedback/components/icons/XCloseIcon.js.map +0 -1
- package/dist/module/features/feedback/model/teacherFeedback.model.js +0 -206
- package/dist/module/features/feedback/model/teacherFeedback.model.js.map +0 -1
- package/dist/module/features/feedback/types/teacherFeedback.types.js +0 -14
- package/dist/module/features/feedback/types/teacherFeedback.types.js.map +0 -1
- package/dist/typescript/commonjs/features/feedback/components/EmptyComment/EmptyComment.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/feedback/components/ListCardCommentsCount/ListCardCommentsCount.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/feedback/components/icons/MessageBubbleIcon.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/feedback/components/icons/XCloseIcon.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/feedback/model/teacherFeedback.model.d.ts +0 -45
- package/dist/typescript/commonjs/features/feedback/model/teacherFeedback.model.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/feedback/types/teacherFeedback.types.d.ts +0 -33
- package/dist/typescript/commonjs/features/feedback/types/teacherFeedback.types.d.ts.map +0 -1
- package/dist/typescript/module/features/feedback/components/EmptyComment/EmptyComment.d.ts.map +0 -1
- package/dist/typescript/module/features/feedback/components/ListCardCommentsCount/ListCardCommentsCount.d.ts.map +0 -1
- package/dist/typescript/module/features/feedback/components/icons/MessageBubbleIcon.d.ts.map +0 -1
- package/dist/typescript/module/features/feedback/components/icons/XCloseIcon.d.ts.map +0 -1
- package/dist/typescript/module/features/feedback/model/teacherFeedback.model.d.ts +0 -45
- package/dist/typescript/module/features/feedback/model/teacherFeedback.model.d.ts.map +0 -1
- package/dist/typescript/module/features/feedback/types/teacherFeedback.types.d.ts +0 -33
- package/dist/typescript/module/features/feedback/types/teacherFeedback.types.d.ts.map +0 -1
- package/src/features/feedback/model/teacherFeedback.model.ts +0 -268
- package/src/features/feedback/types/teacherFeedback.types.ts +0 -32
- /package/dist/commonjs/features/feedback/{components → assets}/icons/MessageBubbleIcon.js +0 -0
- /package/dist/commonjs/features/feedback/{components → assets}/icons/XCloseIcon.js +0 -0
- /package/dist/module/features/feedback/{components → assets}/icons/MessageBubbleIcon.js +0 -0
- /package/dist/module/features/feedback/{components → assets}/icons/XCloseIcon.js +0 -0
- /package/dist/typescript/commonjs/features/feedback/{components → assets}/icons/MessageBubbleIcon.d.ts +0 -0
- /package/dist/typescript/commonjs/features/feedback/{components → assets}/icons/XCloseIcon.d.ts +0 -0
- /package/dist/typescript/commonjs/features/feedback/components/{ListCardCommentsCount/ListCardCommentsCount.d.ts → ListCardCommentsCount.d.ts} +0 -0
- /package/dist/typescript/module/features/feedback/{components → assets}/icons/MessageBubbleIcon.d.ts +0 -0
- /package/dist/typescript/module/features/feedback/{components → assets}/icons/XCloseIcon.d.ts +0 -0
- /package/dist/typescript/module/features/feedback/components/{ListCardCommentsCount/ListCardCommentsCount.d.ts → ListCardCommentsCount.d.ts} +0 -0
- /package/src/features/feedback/{components → assets}/icons/MessageBubbleIcon.tsx +0 -0
- /package/src/features/feedback/{components → assets}/icons/XCloseIcon.tsx +0 -0
|
@@ -3,4 +3,45 @@ export declare const LOCALIZATION_CONFIGS: {
|
|
|
3
3
|
"en-GB": {};
|
|
4
4
|
"sv-SE": {};
|
|
5
5
|
};
|
|
6
|
+
export declare const RELATIVE_TIME_LABELS: {
|
|
7
|
+
"en-SE": {
|
|
8
|
+
justNow: string;
|
|
9
|
+
minuteAgo: string;
|
|
10
|
+
minutesAgo: string;
|
|
11
|
+
hourAgo: string;
|
|
12
|
+
hoursAgo: string;
|
|
13
|
+
dayAgo: string;
|
|
14
|
+
daysAgo: string;
|
|
15
|
+
monthAgo: string;
|
|
16
|
+
monthsAgo: string;
|
|
17
|
+
yearAgo: string;
|
|
18
|
+
yearsAgo: string;
|
|
19
|
+
};
|
|
20
|
+
"sv-SE": {
|
|
21
|
+
justNow: string;
|
|
22
|
+
minuteAgo: string;
|
|
23
|
+
minutesAgo: string;
|
|
24
|
+
hourAgo: string;
|
|
25
|
+
hoursAgo: string;
|
|
26
|
+
dayAgo: string;
|
|
27
|
+
daysAgo: string;
|
|
28
|
+
monthAgo: string;
|
|
29
|
+
monthsAgo: string;
|
|
30
|
+
yearAgo: string;
|
|
31
|
+
yearsAgo: string;
|
|
32
|
+
};
|
|
33
|
+
"en-GB": {
|
|
34
|
+
justNow: string;
|
|
35
|
+
minuteAgo: string;
|
|
36
|
+
minutesAgo: string;
|
|
37
|
+
hourAgo: string;
|
|
38
|
+
hoursAgo: string;
|
|
39
|
+
dayAgo: string;
|
|
40
|
+
daysAgo: string;
|
|
41
|
+
monthAgo: string;
|
|
42
|
+
monthsAgo: string;
|
|
43
|
+
yearAgo: string;
|
|
44
|
+
yearsAgo: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
6
47
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { StyleSheet, Text, View } from 'react-native'
|
|
3
3
|
import { COLORS } from '@magmamath/react-native-ui'
|
|
4
|
-
import { BUENOS_AIRES_FONT, NO_COMMENTS_SWE, NO_COMMENTS_ENG } from '
|
|
5
|
-
import { Locale } from '
|
|
4
|
+
import { BUENOS_AIRES_FONT, NO_COMMENTS_SWE, NO_COMMENTS_ENG } from '../constants'
|
|
5
|
+
import { Locale } from '../../../shared/translation/types'
|
|
6
6
|
|
|
7
7
|
type EmptyCommentProps = {
|
|
8
8
|
locale: Locale | null
|
|
@@ -11,7 +11,7 @@ type EmptyCommentProps = {
|
|
|
11
11
|
export const EmptyComment = ({ locale }: EmptyCommentProps) => {
|
|
12
12
|
return (
|
|
13
13
|
<View style={styles.container}>
|
|
14
|
-
<Text style={styles.text}>{locale === Locale.
|
|
14
|
+
<Text style={styles.text}>{locale === Locale.SW ? NO_COMMENTS_SWE : NO_COMMENTS_ENG}</Text>
|
|
15
15
|
</View>
|
|
16
16
|
)
|
|
17
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { Text, View, StyleSheet } from 'react-native'
|
|
3
|
-
import { MessageBubbleIcon } from '../icons/MessageBubbleIcon'
|
|
3
|
+
import { MessageBubbleIcon } from '../assets/icons/MessageBubbleIcon'
|
|
4
4
|
import { COLORS } from '@magmamath/react-native-ui'
|
|
5
|
-
import { BUENOS_AIRES_FONT } from '
|
|
5
|
+
import { BUENOS_AIRES_FONT } from '../constants'
|
|
6
6
|
|
|
7
7
|
type ListCardCommentsCountProps = {
|
|
8
8
|
count: number
|
|
@@ -3,24 +3,32 @@ import { useStoreMap, useUnit } from 'effector-react'
|
|
|
3
3
|
import { View, StyleSheet } from 'react-native'
|
|
4
4
|
import { TeacherFeedbackButton } from './TeacherFeedbackButton/TeacherFeedbackButton'
|
|
5
5
|
import { TeacherFeedbackComments } from './TeacherFeedbackComments/TeacherFeedbackComments'
|
|
6
|
-
import { TeacherFeedbackModel } from '../model/teacherFeedback.model'
|
|
7
6
|
import { FeedbackButtonColors, FeedbackButtonSize, FeedbackMode } from '../constants'
|
|
7
|
+
import { TeacherFeedbackModel } from '../model/model'
|
|
8
|
+
import { Locale } from '../../../shared/translation'
|
|
8
9
|
|
|
9
10
|
type TeacherFeedbackProps = {
|
|
10
11
|
model: TeacherFeedbackModel
|
|
11
12
|
mode: FeedbackMode
|
|
13
|
+
locale: Locale
|
|
14
|
+
assignmentId: string
|
|
15
|
+
problemId: string
|
|
12
16
|
isExam: boolean
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
export const TeacherFeedback = ({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
export const TeacherFeedback = ({
|
|
20
|
+
model,
|
|
21
|
+
mode,
|
|
22
|
+
assignmentId,
|
|
23
|
+
problemId,
|
|
24
|
+
locale,
|
|
25
|
+
isExam = false,
|
|
26
|
+
}: TeacherFeedbackProps) => {
|
|
27
|
+
const isOpen = useUnit(model.$isOpen)
|
|
28
|
+
const isLoading = useUnit(model.api.getCommentsFx.pending)
|
|
21
29
|
const teacherFeedback = useStoreMap({
|
|
22
|
-
store: model.$
|
|
23
|
-
fn: (feedback, [assignmentId, problemId]) => feedback
|
|
30
|
+
store: model.comments.$data,
|
|
31
|
+
fn: (feedback, [assignmentId, problemId]) => feedback?.get(assignmentId)?.[problemId] ?? null,
|
|
24
32
|
keys: [assignmentId, problemId],
|
|
25
33
|
})
|
|
26
34
|
|
|
@@ -28,9 +36,11 @@ export const TeacherFeedback = ({ model, mode, isExam = false }: TeacherFeedback
|
|
|
28
36
|
|
|
29
37
|
return (
|
|
30
38
|
<View style={styles.container}>
|
|
31
|
-
{isOpen &&
|
|
39
|
+
{isOpen && (
|
|
40
|
+
<TeacherFeedbackComments comments={teacherFeedback.comments} locale={locale} mode={mode} />
|
|
41
|
+
)}
|
|
32
42
|
<TeacherFeedbackButton
|
|
33
|
-
onPress={() => model.
|
|
43
|
+
onPress={() => model.setIsOpen(!isOpen)}
|
|
34
44
|
unreadCommentsCount={teacherFeedback.unreadMessagesCount}
|
|
35
45
|
isOpen={isOpen}
|
|
36
46
|
isLoading={isLoading}
|
|
@@ -2,8 +2,8 @@ import React from 'react'
|
|
|
2
2
|
import { StyleSheet, View } from 'react-native'
|
|
3
3
|
import { Button, COLORS } from '@magmamath/react-native-ui'
|
|
4
4
|
import { UnreadMessagesBadge } from '../UnreadMessagesBadge'
|
|
5
|
-
import { MessageBubbleIcon } from '
|
|
6
|
-
import { XCloseIcon } from '
|
|
5
|
+
import { MessageBubbleIcon } from '../../assets/icons/MessageBubbleIcon'
|
|
6
|
+
import { XCloseIcon } from '../../assets/icons/XCloseIcon'
|
|
7
7
|
import { COLOR_SCHEMES } from './colorSchemes'
|
|
8
8
|
import {
|
|
9
9
|
FeedbackButtonColors,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { View, Text, StyleSheet } from 'react-native'
|
|
3
3
|
import { COLORS } from '@magmamath/react-native-ui'
|
|
4
|
-
import { getRelativeTime } from '../../helpers'
|
|
5
4
|
import { BUENOS_AIRES_FONT } from '../../constants'
|
|
6
|
-
import {
|
|
5
|
+
import { getRelativeTimeText } from '../../../../lib/helpers/helpers'
|
|
6
|
+
import { Locale } from '@magmamath/students-features'
|
|
7
7
|
|
|
8
8
|
type TeacherCommentProps = {
|
|
9
9
|
content: string
|
|
@@ -13,7 +13,13 @@ type TeacherCommentProps = {
|
|
|
13
13
|
isLastComment: boolean
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const TeacherComment = ({
|
|
16
|
+
export const TeacherComment = ({
|
|
17
|
+
content,
|
|
18
|
+
teacherName,
|
|
19
|
+
createdAt,
|
|
20
|
+
locale,
|
|
21
|
+
isLastComment,
|
|
22
|
+
}: TeacherCommentProps) => {
|
|
17
23
|
return (
|
|
18
24
|
<View style={{ marginBottom: isLastComment ? 8 : 0 }}>
|
|
19
25
|
<View style={styles.authorInfo}>
|
|
@@ -22,7 +28,7 @@ export const TeacherComment = ({ content, teacherName, createdAt, locale, isLast
|
|
|
22
28
|
</Text>
|
|
23
29
|
<View style={styles.spacer} />
|
|
24
30
|
<Text style={styles.dateAdded} numberOfLines={1}>
|
|
25
|
-
{
|
|
31
|
+
{getRelativeTimeText(createdAt, locale ?? Locale.EN)}
|
|
26
32
|
</Text>
|
|
27
33
|
</View>
|
|
28
34
|
|
package/src/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.tsx
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react'
|
|
2
2
|
import { Platform, ScrollView, StyleSheet, useWindowDimensions, View } from 'react-native'
|
|
3
|
-
import { Locale, TeacherComment as FeedbackComment } from '../../types/teacherFeedback.types'
|
|
4
3
|
import { TeacherComment } from './TeacherComment'
|
|
5
|
-
import { EmptyComment } from '../EmptyComment
|
|
4
|
+
import { EmptyComment } from '../EmptyComment'
|
|
6
5
|
import { EMPTY_COMMENT_ID, FeedbackMode } from '../../constants'
|
|
7
6
|
import { COLORS } from '@magmamath/react-native-ui'
|
|
7
|
+
import { Locale } from '../../../../shared/translation'
|
|
8
|
+
import { TeacherComment as TeacherCommentEntity } from '../../types'
|
|
8
9
|
|
|
9
10
|
const TOOLBAR_HEIGHT = 140
|
|
10
11
|
const BOTTOM_OFFSET = Platform.OS === 'web' ? 270 : 304
|
|
11
12
|
const SIMPLE_MODE_OFFSET = 70
|
|
12
13
|
|
|
13
14
|
type TeacherFeedbackCommentsProps = {
|
|
14
|
-
comments:
|
|
15
|
+
comments: TeacherCommentEntity[] | null
|
|
15
16
|
locale: Locale | null
|
|
16
17
|
mode: FeedbackMode
|
|
17
18
|
}
|
|
@@ -2,4 +2,4 @@ export { TeacherFeedbackComments } from './TeacherFeedbackComments/TeacherFeedba
|
|
|
2
2
|
export { TeacherFeedbackButton } from './TeacherFeedbackButton/TeacherFeedbackButton'
|
|
3
3
|
export { TeacherFeedback } from './TeacherFeedback'
|
|
4
4
|
export { UnreadMessagesBadge } from './UnreadMessagesBadge'
|
|
5
|
-
export { ListCardCommentsCount } from './ListCardCommentsCount
|
|
5
|
+
export { ListCardCommentsCount } from './ListCardCommentsCount'
|
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
|
-
import { Locale } from './types/teacherFeedback.types'
|
|
3
2
|
|
|
4
|
-
export const BUENOS_AIRES_FONT =
|
|
3
|
+
export const BUENOS_AIRES_FONT =
|
|
4
|
+
Platform.OS === 'web' ? 'Buenos Aires, sans-serif' : 'BuenosAires-Regular'
|
|
5
5
|
|
|
6
6
|
export const NO_COMMENTS_ENG = 'No comments yet'
|
|
7
7
|
export const NO_COMMENTS_SWE = 'Inga kommentarer än'
|
|
8
8
|
export const EMPTY_COMMENT_ID = 'empty-comment'
|
|
9
9
|
|
|
10
|
-
export const getEmptyComment = (problemId: string, locale: Locale | null) => {
|
|
11
|
-
return {
|
|
12
|
-
__v: 0,
|
|
13
|
-
_id: EMPTY_COMMENT_ID,
|
|
14
|
-
content: locale === Locale.SV ? NO_COMMENTS_SWE : NO_COMMENTS_ENG,
|
|
15
|
-
createdAt: new Date(),
|
|
16
|
-
exerciseId: '',
|
|
17
|
-
isRead: true,
|
|
18
|
-
problemId,
|
|
19
|
-
studentId: '',
|
|
20
|
-
teacherId: '',
|
|
21
|
-
teacherName: '',
|
|
22
|
-
updatedAt: new Date(),
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
10
|
export const TEACHER_FEEDBACK_BUTTON_ID = 'teacherFeedbackButton'
|
|
27
11
|
|
|
28
12
|
export enum FeedbackButtonColors {
|
|
@@ -1,66 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommentsMap, FeedbackEntity, GetCommentsResponse } from './types'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
monthAgo: 'month ago',
|
|
13
|
-
monthsAgo: 'months ago',
|
|
14
|
-
yearAgo: 'year ago',
|
|
15
|
-
yearsAgo: 'years ago',
|
|
16
|
-
},
|
|
17
|
-
[Locale.SV]: {
|
|
18
|
-
justNow: 'alldeles nyss',
|
|
19
|
-
minuteAgo: 'minut sedan',
|
|
20
|
-
minutesAgo: 'minuter sedan',
|
|
21
|
-
hourAgo: 'timme sedan',
|
|
22
|
-
hoursAgo: 'timmar sedan',
|
|
23
|
-
dayAgo: 'dag sedan',
|
|
24
|
-
daysAgo: 'dagar sedan',
|
|
25
|
-
monthAgo: 'månad sedan',
|
|
26
|
-
monthsAgo: 'månader sedan',
|
|
27
|
-
yearAgo: 'år sedan',
|
|
28
|
-
yearsAgo: 'år sedan',
|
|
29
|
-
},
|
|
30
|
-
[Locale.GB]: {
|
|
31
|
-
justNow: 'just now',
|
|
32
|
-
minuteAgo: 'minute ago',
|
|
33
|
-
minutesAgo: 'minutes ago',
|
|
34
|
-
hourAgo: 'hour ago',
|
|
35
|
-
hoursAgo: 'hours ago',
|
|
36
|
-
dayAgo: 'day ago',
|
|
37
|
-
daysAgo: 'days ago',
|
|
38
|
-
monthAgo: 'month ago',
|
|
39
|
-
monthsAgo: 'months ago',
|
|
40
|
-
yearAgo: 'year ago',
|
|
41
|
-
yearsAgo: 'years ago',
|
|
42
|
-
},
|
|
43
|
-
}
|
|
3
|
+
export function generateCommentsMap(assignmentId: string, data: GetCommentsResponse): CommentsMap {
|
|
4
|
+
const problemsMap = Object.entries(data).reduce<Record<string, FeedbackEntity>>(
|
|
5
|
+
(acc, [problemId, feedback]) => {
|
|
6
|
+
const unreadMessages = feedback.comments.filter(({ isRead }) => !isRead)
|
|
7
|
+
|
|
8
|
+
acc[problemId] = {
|
|
9
|
+
comments: feedback.comments,
|
|
10
|
+
unreadMessagesCount: unreadMessages.length,
|
|
11
|
+
}
|
|
44
12
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
13
|
+
return acc
|
|
14
|
+
},
|
|
15
|
+
{},
|
|
16
|
+
)
|
|
48
17
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const diffTime = now - targetDate
|
|
18
|
+
return new Map().set(assignmentId, problemsMap)
|
|
19
|
+
}
|
|
52
20
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const years = Math.floor(days / 365)
|
|
21
|
+
type FindCommentsByCreditsProps = {
|
|
22
|
+
data: CommentsMap | null
|
|
23
|
+
assignmentId: string
|
|
24
|
+
problemId: string
|
|
25
|
+
}
|
|
59
26
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
27
|
+
export function findCommentsByCredits({
|
|
28
|
+
data,
|
|
29
|
+
assignmentId,
|
|
30
|
+
problemId,
|
|
31
|
+
}: FindCommentsByCreditsProps) {
|
|
32
|
+
return data?.get(assignmentId)?.[problemId]?.comments ?? []
|
|
66
33
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createEffect, Effect } from 'effector'
|
|
2
|
+
import { TeacherFeedbackModelProps } from './model'
|
|
3
|
+
import { GetCommentsPayload, GetCommentsResponse, UpdateCommentStatusSeenPayload } from '../types'
|
|
4
|
+
|
|
5
|
+
export class TeacherFeedbackAPI {
|
|
6
|
+
public readonly getCommentsFx: Effect<GetCommentsPayload, GetCommentsResponse>
|
|
7
|
+
public readonly updateCommentStatusSeenFx: Effect<UpdateCommentStatusSeenPayload, void>
|
|
8
|
+
|
|
9
|
+
constructor(api: TeacherFeedbackModelProps['api']) {
|
|
10
|
+
this.getCommentsFx = createEffect(api.getComments)
|
|
11
|
+
this.updateCommentStatusSeenFx = createEffect(api.updateCommentStatusSeen)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { createEvent, restore, sample, Store } from 'effector'
|
|
2
|
+
import { CommentsMap, Credits, FeedbackEntity, NoCommentsMessage, TeacherComment } from '../types'
|
|
3
|
+
import { TeacherFeedbackAPI } from './api'
|
|
4
|
+
import { TeacherFeedbackModelProps } from './model'
|
|
5
|
+
|
|
6
|
+
type UpdateProps = {
|
|
7
|
+
state: CommentsMap | null
|
|
8
|
+
assignmentId: string
|
|
9
|
+
problemId: string
|
|
10
|
+
fn: (data: FeedbackEntity) => FeedbackEntity | undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class TeacherComments {
|
|
14
|
+
private readonly setNoCommentsMessage = createEvent<TeacherComment>()
|
|
15
|
+
public readonly setAllCommentsRead = createEvent<Credits>()
|
|
16
|
+
public readonly add = createEvent<Credits & { comment: TeacherComment; isRead: boolean }>()
|
|
17
|
+
public readonly delete = createEvent<Credits & { commentId: string }>()
|
|
18
|
+
|
|
19
|
+
public readonly setData = createEvent<CommentsMap>()
|
|
20
|
+
public readonly $data = restore<CommentsMap | null>(this.setData, null)
|
|
21
|
+
.on(this.setAllCommentsRead, (state, { assignmentId, problemId }) =>
|
|
22
|
+
this.update({
|
|
23
|
+
state,
|
|
24
|
+
assignmentId,
|
|
25
|
+
problemId,
|
|
26
|
+
fn: data => ({
|
|
27
|
+
comments: data.comments.map(comment => ({ ...comment, isRead: true })),
|
|
28
|
+
unreadMessagesCount: 0,
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
.on(this.add, (state, { assignmentId, problemId, comment, isRead }) =>
|
|
33
|
+
this.update({
|
|
34
|
+
state,
|
|
35
|
+
assignmentId,
|
|
36
|
+
problemId,
|
|
37
|
+
fn: data => ({
|
|
38
|
+
comments: [...data.comments, comment],
|
|
39
|
+
unreadMessagesCount: isRead ? data.unreadMessagesCount : data.unreadMessagesCount + 1,
|
|
40
|
+
}),
|
|
41
|
+
}),
|
|
42
|
+
)
|
|
43
|
+
.on(this.delete, (state, { assignmentId, problemId, commentId }) =>
|
|
44
|
+
this.update({
|
|
45
|
+
state,
|
|
46
|
+
assignmentId,
|
|
47
|
+
problemId,
|
|
48
|
+
fn: data => {
|
|
49
|
+
const commentToDelete = data.comments.find(({ _id }) => _id === commentId)
|
|
50
|
+
if (!commentToDelete) return data
|
|
51
|
+
|
|
52
|
+
const filteredComments = data.comments.filter(({ _id }) => _id !== commentId)
|
|
53
|
+
if (!filteredComments.length) return undefined
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
comments: filteredComments,
|
|
57
|
+
unreadMessagesCount: commentToDelete.isRead
|
|
58
|
+
? data.unreadMessagesCount
|
|
59
|
+
: data.unreadMessagesCount - 1,
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
)
|
|
64
|
+
.on(this.setNoCommentsMessage, (state, noCommentsMessage) =>
|
|
65
|
+
this.update({
|
|
66
|
+
state,
|
|
67
|
+
assignmentId: noCommentsMessage.exerciseId,
|
|
68
|
+
problemId: noCommentsMessage.problemId,
|
|
69
|
+
fn: () => ({
|
|
70
|
+
comments: [noCommentsMessage],
|
|
71
|
+
unreadMessagesCount: 0,
|
|
72
|
+
}),
|
|
73
|
+
}),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
constructor(
|
|
77
|
+
api: TeacherFeedbackAPI,
|
|
78
|
+
$isOpen: Store<boolean>,
|
|
79
|
+
EMPTY_COMMENT: TeacherFeedbackModelProps['defaults']['EMPTY_COMMENT'],
|
|
80
|
+
) {
|
|
81
|
+
sample({
|
|
82
|
+
clock: this.add,
|
|
83
|
+
source: { isOpen: $isOpen },
|
|
84
|
+
filter: ({ isOpen }) => isOpen,
|
|
85
|
+
fn: (_, { comment }) => ({
|
|
86
|
+
ids: [comment._id],
|
|
87
|
+
}),
|
|
88
|
+
target: api.updateCommentStatusSeenFx,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// Adds message "No comments yet" after removing last comment and list is open
|
|
92
|
+
sample({
|
|
93
|
+
clock: this.delete,
|
|
94
|
+
source: { isOpen: $isOpen, state: this.$data },
|
|
95
|
+
filter: ({ isOpen, state }, deletedMessage) => {
|
|
96
|
+
const hasNoMessages = !state?.get(deletedMessage.assignmentId)?.[deletedMessage.problemId]
|
|
97
|
+
?.comments.length
|
|
98
|
+
return isOpen && hasNoMessages
|
|
99
|
+
},
|
|
100
|
+
fn: (_, { assignmentId, problemId }) => ({
|
|
101
|
+
...EMPTY_COMMENT,
|
|
102
|
+
exerciseId: assignmentId,
|
|
103
|
+
problemId,
|
|
104
|
+
}),
|
|
105
|
+
target: this.setNoCommentsMessage,
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private update({ state, assignmentId, problemId, fn }: UpdateProps) {
|
|
110
|
+
if (!state) return state
|
|
111
|
+
|
|
112
|
+
const updatedState = new Map(state)
|
|
113
|
+
const assignmentMap = updatedState.get(assignmentId) || {}
|
|
114
|
+
const currentData = assignmentMap[problemId] || { comments: [], unreadMessagesCount: 0 }
|
|
115
|
+
const updatedData = fn(currentData)
|
|
116
|
+
|
|
117
|
+
if (updatedData === undefined) {
|
|
118
|
+
delete assignmentMap[problemId]
|
|
119
|
+
if (Object.keys(assignmentMap).length === 0) updatedState.delete(assignmentId)
|
|
120
|
+
return updatedState
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
assignmentMap[problemId] = updatedData
|
|
124
|
+
updatedState.set(assignmentId, assignmentMap)
|
|
125
|
+
return updatedState
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createEvent, restore, sample, Store } from 'effector'
|
|
2
|
+
import { TeacherFeedbackAPI } from './api'
|
|
3
|
+
import { TeacherFeedbackSockets } from './sockets'
|
|
4
|
+
import { TeacherComments } from './comments'
|
|
5
|
+
import { findCommentsByCredits, generateCommentsMap } from '../helpers'
|
|
6
|
+
import {
|
|
7
|
+
GetCommentsPayload,
|
|
8
|
+
GetCommentsResponse,
|
|
9
|
+
NoCommentsMessage,
|
|
10
|
+
UpdateCommentStatusSeenPayload,
|
|
11
|
+
} from '../types'
|
|
12
|
+
import { EMPTY_COMMENT_ID } from '../constants'
|
|
13
|
+
|
|
14
|
+
export type TeacherFeedbackModelProps = {
|
|
15
|
+
api: {
|
|
16
|
+
getComments: (props: GetCommentsPayload) => Promise<GetCommentsResponse>
|
|
17
|
+
updateCommentStatusSeen: (props: UpdateCommentStatusSeenPayload) => Promise<void>
|
|
18
|
+
}
|
|
19
|
+
socket: any
|
|
20
|
+
credits: {
|
|
21
|
+
$assignmentId: Store<string>
|
|
22
|
+
$problemId: Store<string>
|
|
23
|
+
}
|
|
24
|
+
defaults: { EMPTY_COMMENT: NoCommentsMessage }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class TeacherFeedbackModel {
|
|
28
|
+
public readonly sockets: TeacherFeedbackSockets
|
|
29
|
+
public readonly api: TeacherFeedbackAPI
|
|
30
|
+
public readonly comments: TeacherComments
|
|
31
|
+
public readonly setIsOpen = createEvent<boolean>()
|
|
32
|
+
public readonly $isOpen = restore(this.setIsOpen, false)
|
|
33
|
+
|
|
34
|
+
constructor({ api, socket, credits, defaults }: TeacherFeedbackModelProps) {
|
|
35
|
+
this.api = new TeacherFeedbackAPI(api)
|
|
36
|
+
this.sockets = new TeacherFeedbackSockets(socket)
|
|
37
|
+
this.comments = new TeacherComments(this.api, this.$isOpen, defaults.EMPTY_COMMENT)
|
|
38
|
+
|
|
39
|
+
sample({
|
|
40
|
+
clock: credits.$problemId,
|
|
41
|
+
fn: () => false,
|
|
42
|
+
target: this.setIsOpen,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// Deletes entity when closing list with no comments
|
|
46
|
+
sample({
|
|
47
|
+
clock: this.setIsOpen,
|
|
48
|
+
source: {
|
|
49
|
+
data: this.comments.$data,
|
|
50
|
+
assignmentId: credits.$assignmentId,
|
|
51
|
+
problemId: credits.$problemId,
|
|
52
|
+
},
|
|
53
|
+
filter: ({ data, assignmentId, problemId }, isOpen) => {
|
|
54
|
+
const comments = data?.get(assignmentId)?.[problemId].comments
|
|
55
|
+
const isOnlyNoCommentsMessage =
|
|
56
|
+
comments?.length === 1 && comments[0]._id === EMPTY_COMMENT_ID
|
|
57
|
+
return !isOpen && isOnlyNoCommentsMessage
|
|
58
|
+
},
|
|
59
|
+
fn: ({ assignmentId, problemId }, comment) => ({
|
|
60
|
+
assignmentId,
|
|
61
|
+
problemId,
|
|
62
|
+
commentId: EMPTY_COMMENT_ID,
|
|
63
|
+
}),
|
|
64
|
+
target: this.comments.delete,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
sample({
|
|
68
|
+
clock: this.setIsOpen,
|
|
69
|
+
source: {
|
|
70
|
+
data: this.comments.$data,
|
|
71
|
+
assignmentId: credits.$assignmentId,
|
|
72
|
+
problemId: credits.$problemId,
|
|
73
|
+
},
|
|
74
|
+
filter: (source, isOpen) => {
|
|
75
|
+
const comments = findCommentsByCredits(source)
|
|
76
|
+
const hasUnreadComments = comments.some(({ isRead }) => !isRead)
|
|
77
|
+
return isOpen && hasUnreadComments
|
|
78
|
+
},
|
|
79
|
+
fn: source => {
|
|
80
|
+
const comments = findCommentsByCredits(source)
|
|
81
|
+
return { ids: comments.map(({ _id }) => _id) }
|
|
82
|
+
},
|
|
83
|
+
target: this.api.updateCommentStatusSeenFx,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
sample({
|
|
87
|
+
clock: this.api.updateCommentStatusSeenFx.pending,
|
|
88
|
+
source: { assignmentId: credits.$assignmentId, problemId: credits.$problemId },
|
|
89
|
+
target: this.comments.setAllCommentsRead,
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
sample({
|
|
93
|
+
clock: this.api.getCommentsFx.done,
|
|
94
|
+
fn: ({ params, result }) => generateCommentsMap(params.id, result),
|
|
95
|
+
target: this.comments.setData,
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
sample({
|
|
99
|
+
clock: this.sockets.commentDeleted,
|
|
100
|
+
source: { assignmentId: credits.$assignmentId },
|
|
101
|
+
fn: ({ assignmentId }, comment) => ({
|
|
102
|
+
assignmentId,
|
|
103
|
+
problemId: comment.problemId,
|
|
104
|
+
commentId: comment._id,
|
|
105
|
+
}),
|
|
106
|
+
target: this.comments.delete,
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
sample({
|
|
110
|
+
clock: this.sockets.commentAdded,
|
|
111
|
+
source: {
|
|
112
|
+
assignmentId: credits.$assignmentId,
|
|
113
|
+
problemId: credits.$problemId,
|
|
114
|
+
isOpen: this.$isOpen,
|
|
115
|
+
},
|
|
116
|
+
fn: ({ assignmentId, problemId, isOpen }, comment) => ({
|
|
117
|
+
comment,
|
|
118
|
+
assignmentId,
|
|
119
|
+
problemId: comment.problemId,
|
|
120
|
+
isRead: isOpen && comment.problemId === problemId,
|
|
121
|
+
}),
|
|
122
|
+
target: this.comments.add,
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createEvent } from 'effector'
|
|
2
|
+
import { TeacherComment, FeedbackSocketEvents } from '../types'
|
|
3
|
+
|
|
4
|
+
export class TeacherFeedbackSockets {
|
|
5
|
+
private readonly socket: any
|
|
6
|
+
public readonly commentAdded = createEvent<TeacherComment>()
|
|
7
|
+
public readonly commentDeleted = createEvent<TeacherComment>()
|
|
8
|
+
|
|
9
|
+
constructor(socket: any) {
|
|
10
|
+
this.socket = socket
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
connect() {
|
|
14
|
+
this.socket.on(FeedbackSocketEvents.COMMENT_ADDED, this.commentAdded)
|
|
15
|
+
this.socket.on(FeedbackSocketEvents.COMMENT_DELETED, this.commentDeleted)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
off() {
|
|
19
|
+
this.socket.off(FeedbackSocketEvents.COMMENT_ADDED, this.commentAdded)
|
|
20
|
+
this.socket.off(FeedbackSocketEvents.COMMENT_DELETED, this.commentDeleted)
|
|
21
|
+
}
|
|
22
|
+
}
|