@magmamath/students-features 0.2.0-fix1 → 0.2.0-hotfix-circular-dependencies-chatbot

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.
Files changed (59) hide show
  1. package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +21 -5
  2. package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
  3. package/dist/commonjs/features/chatbot/model/model.js +12 -2
  4. package/dist/commonjs/features/chatbot/model/model.js.map +1 -1
  5. package/dist/commonjs/features/chatbot/model/t2s.js +8 -4
  6. package/dist/commonjs/features/chatbot/model/t2s.js.map +1 -1
  7. package/dist/commonjs/features/chatbot/model/translation.js +30 -15
  8. package/dist/commonjs/features/chatbot/model/translation.js.map +1 -1
  9. package/dist/commonjs/features/feedback/components/EmptyComment/EmptyComment.js +2 -3
  10. package/dist/commonjs/features/feedback/components/EmptyComment/EmptyComment.js.map +1 -1
  11. package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +15 -2
  12. package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
  13. package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +1 -1
  14. package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
  15. package/dist/commonjs/features/feedback/components/UnreadMessagesBadge.js +6 -3
  16. package/dist/commonjs/features/feedback/components/UnreadMessagesBadge.js.map +1 -1
  17. package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +22 -6
  18. package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
  19. package/dist/module/features/chatbot/model/model.js +12 -2
  20. package/dist/module/features/chatbot/model/model.js.map +1 -1
  21. package/dist/module/features/chatbot/model/t2s.js +8 -4
  22. package/dist/module/features/chatbot/model/t2s.js.map +1 -1
  23. package/dist/module/features/chatbot/model/translation.js +30 -15
  24. package/dist/module/features/chatbot/model/translation.js.map +1 -1
  25. package/dist/module/features/feedback/components/EmptyComment/EmptyComment.js +2 -3
  26. package/dist/module/features/feedback/components/EmptyComment/EmptyComment.js.map +1 -1
  27. package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +15 -2
  28. package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
  29. package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +1 -1
  30. package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
  31. package/dist/module/features/feedback/components/UnreadMessagesBadge.js +6 -3
  32. package/dist/module/features/feedback/components/UnreadMessagesBadge.js.map +1 -1
  33. package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
  34. package/dist/typescript/commonjs/features/chatbot/model/model.d.ts.map +1 -1
  35. package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts +7 -5
  36. package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts.map +1 -1
  37. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +10 -5
  38. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
  39. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
  40. package/dist/typescript/commonjs/features/feedback/components/UnreadMessagesBadge.d.ts +3 -2
  41. package/dist/typescript/commonjs/features/feedback/components/UnreadMessagesBadge.d.ts.map +1 -1
  42. package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
  43. package/dist/typescript/module/features/chatbot/model/model.d.ts.map +1 -1
  44. package/dist/typescript/module/features/chatbot/model/t2s.d.ts +7 -5
  45. package/dist/typescript/module/features/chatbot/model/t2s.d.ts.map +1 -1
  46. package/dist/typescript/module/features/chatbot/model/translation.d.ts +10 -5
  47. package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
  48. package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
  49. package/dist/typescript/module/features/feedback/components/UnreadMessagesBadge.d.ts +3 -2
  50. package/dist/typescript/module/features/feedback/components/UnreadMessagesBadge.d.ts.map +1 -1
  51. package/package.json +4 -4
  52. package/src/features/chatbot/components/ChatControls/ChatControls.tsx +27 -4
  53. package/src/features/chatbot/model/model.ts +13 -2
  54. package/src/features/chatbot/model/t2s.ts +13 -7
  55. package/src/features/chatbot/model/translation.ts +46 -27
  56. package/src/features/feedback/components/EmptyComment/EmptyComment.tsx +1 -2
  57. package/src/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.tsx +11 -2
  58. package/src/features/feedback/components/TeacherFeedbackComments/TeacherComment.tsx +1 -1
  59. package/src/features/feedback/components/UnreadMessagesBadge.tsx +7 -4
@@ -1,14 +1,16 @@
1
- import { ChatbotModel } from './model';
1
+ import { StoreWritable } from 'effector';
2
2
  import { AudioProvider, AudioStatus, PlayTextToSpeechProps } from '../types/t2s.types';
3
+ import { ChatbotAPI } from './api';
3
4
  export declare class ChatTextToSpeech {
4
- private readonly model;
5
5
  private readonly audioCache;
6
6
  private audioProvider;
7
7
  readonly setCurrentPlayingId: import("effector").EventCallable<string | null>;
8
- readonly $currentPlayingId: import("effector").StoreWritable<string | null>;
8
+ readonly $currentPlayingId: StoreWritable<string | null>;
9
9
  readonly setStatus: import("effector").EventCallable<AudioStatus>;
10
- readonly $status: import("effector").StoreWritable<AudioStatus>;
11
- constructor(chatbotModel: ChatbotModel);
10
+ readonly $status: StoreWritable<AudioStatus>;
11
+ readonly $isOpen: StoreWritable<boolean>;
12
+ readonly api: ChatbotAPI;
13
+ constructor({ $isOpen, api }: any);
12
14
  setAudioProvider(audioProvider: AudioProvider): void;
13
15
  private getCacheKey;
14
16
  play({ text, messageId, isTranslated, config }: PlayTextToSpeechProps): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"t2s.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatb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AAQ,CAAC,GAAG,EAAE,UAAU,CAAA;gBAEV,EACV,OAAO,EACK,GAAG,EAChB,EAAE,GAAG;IASC,gBAAgB,CAAC,aAAa,EAAE,aAAa;IAIpD,OAAO,CAAC,WAAW,CAElB;IAEK,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,qBAAqB;IA0DpE,IAAI;IAYJ,KAAK;CAKf"}
@@ -1,16 +1,21 @@
1
- import { type Effect } from 'effector';
2
- import { ChatbotModel } from './model';
1
+ import { type Effect, type Store } from 'effector';
3
2
  import { TranslateAlternativesFxProps, TranslateBatchFxProps, TranslateMessageFxProps } from '../types/translation.types';
4
- import { ConversationMessage } from '../types/model.types';
3
+ import { ChatbotModelProps, ConversationMessage } from '../types/model.types';
5
4
  import { GetAlternativesResponse } from '../types/api.types';
5
+ import { ChatbotAPI } from './api';
6
6
  export declare class ChatbotTranslation {
7
- private readonly model;
8
7
  readonly setIsTranslated: import("effector").EventCallable<boolean>;
9
8
  readonly $isTranslated: import("effector").StoreWritable<boolean>;
10
9
  readonly translateMessageFx: Effect<TranslateMessageFxProps, ConversationMessage>;
11
10
  readonly translateBatchFx: Effect<TranslateBatchFxProps['params'], ConversationMessage[]>;
12
11
  readonly translateAlternativesFx: Effect<TranslateAlternativesFxProps['params'], GetAlternativesResponse | null>;
13
- constructor(chatbotModel: ChatbotModel);
12
+ readonly credits: ChatbotModelProps['credits'];
13
+ readonly $alternatives: Store<GetAlternativesResponse | null>;
14
+ readonly setAlternatives: import("effector").EventCallable<GetAlternativesResponse | null>;
15
+ readonly defaultMessages: ChatbotModelProps['messages'];
16
+ readonly api: ChatbotAPI;
17
+ readonly messages: any;
18
+ constructor({ credits, $alternatives, setAlternatives, defaultMessages, messages, api, }: any);
14
19
  private shouldSkipTranslation;
15
20
  private initTranslationSamples;
16
21
  private createTranslateAlternativesEffect;
@@ -1 +1 @@
1
- {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/translation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,MAAM,EAAU,MAAM,UAAU,CAAA;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EACH,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAG5D,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IAEpC,QAAQ,CAAC,eAAe,4CAAyB;IACjD,QAAQ,CAAC,aAAa,4CAAuC;IAE7D,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,CAAA;IACjF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAA;IACzF,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CACpC,4BAA4B,CAAC,QAAQ,CAAC,EACtC,uBAAuB,GAAG,IAAI,CACjC,CAAA;gBAEW,YAAY,EAAE,YAAY;IAUtC,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,sBAAsB;IAkB9B,OAAO,CAAC,iCAAiC;IAwDzC,OAAO,CAAC,4BAA4B;IAuBpC,OAAO,CAAC,0BAA0B;YA6DpB,uBAAuB;IAmB9B,KAAK;CAGf"}
1
+ {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/translation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,MAAM,EAAU,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAEtG,OAAO,EACH,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,4BAA4B,CAAA;AACnC,OAA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back/components/TeacherFeedbackButton/TeacherFeedbackButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,qBAAqB,+DAM/B,0BAA0B,sBA4D5B,CAAA"}
1
+ {"version":3,"file":"TeacherFeedbackButton.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,qBAAqB,+DAM/B,0BAA0B,sBAgE5B,CAAA"}
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
2
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
3
  type UnreadMessagesBadgeProps = {
4
4
  badgeContent?: number;
5
5
  withBorder?: boolean;
6
6
  style?: StyleProp<ViewStyle>;
7
+ textStyle?: StyleProp<TextStyle>;
7
8
  };
8
- export declare const UnreadMessagesBadge: ({ badgeContent, withBorder, style }: UnreadMessagesBadgeProps) => React.JSX.Element;
9
+ export declare const UnreadMessagesBadge: ({ badgeContent, withBorder, style, textStyle }: UnreadMessagesBadgeProps) => React.JSX.Element;
9
10
  export {};
10
11
  //# sourceMappingURL=UnreadMessagesBadge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnreadMessagesBadge.d.ts","sourceRoot":"","sources":["../../../../../../src/features/feedback/components/UnreadMessagesBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAoC,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGrF,KAAK,wBAAwB,GAAG;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,mBAAmB,wCAAiD,wBAAwB,sBAcxG,CAAA"}
1
+ {"version":3,"file":"UnreadMessagesBadge.d.ts","sourceRoot":"","sources":["../../../../../../src/features/feedback/components/UnreadMessagesBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAoC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGhG,KAAK,wBAAwB,GAAG;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,mBAAmB,mDAA4D,wBAAwB,sBAcnH,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "0.2.0-fix1",
3
+ "version": "0.2.0-hotfix-circular-dependencies-chatbot",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/commonjs/index.js",
@@ -17,17 +17,17 @@
17
17
  "release": "release-it"
18
18
  },
19
19
  "dependencies": {
20
- "@magmamath/react-native-ui": "0.2.15",
21
20
  "effector": "^23.2.3",
22
21
  "effector-react": "^23.2.1"
23
22
  },
24
23
  "peerDependencies": {
25
24
  "react": "*",
26
25
  "react-native": "*",
27
- "react-native-svg": "^15.10.0"
26
+ "react-native-svg": "^15.10.0",
27
+ "@magmamath/react-native-ui": "*"
28
28
  },
29
29
  "devDependencies": {
30
- "@magmamath/react-native-ui": "0.2.15",
30
+ "@magmamath/react-native-ui": "0.3.0",
31
31
  "@react-native/eslint-config": "^0.73.1",
32
32
  "@release-it/conventional-changelog": "^9.0.2",
33
33
  "@types/jest": "^29.5.5",
@@ -1,7 +1,14 @@
1
1
  import React from 'react'
2
2
  import { ComponentType, PropsWithChildren } from 'react'
3
3
  import { ActivityIndicator, Pressable, StyleSheet, View } from 'react-native'
4
- import { Button } from '@magmamath/react-native-ui'
4
+ import {
5
+ Button,
6
+ ButtonColor,
7
+ ButtonSize,
8
+ ButtonStates,
9
+ ButtonVariant,
10
+ COLORS,
11
+ } from '@magmamath/react-native-ui'
5
12
  import { useUnit } from 'effector-react'
6
13
  import { ChatbotModel } from '../../model/model'
7
14
  import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
@@ -49,12 +56,24 @@ export const ChatControls = ({
49
56
  <Button
50
57
  onPress={onPressClose}
51
58
  style={{
52
- container: styles.buttonClose,
53
- button: {
59
+ button: styles.buttonClose,
60
+ }}
61
+ variant={ButtonVariant.PRIMARY}
62
+ size={ButtonSize.LARGE}
63
+ colorScheme={ButtonColor.GRAY}
64
+ raiseLevel={5}
65
+ customColorScheme={{
66
+ [ButtonStates.DEFAULT]: {
54
67
  backgroundColor: '#FFF',
68
+ borderColor: COLORS.NEUTRAL_5,
69
+ raiseColor: COLORS.NEUTRAL_5,
70
+ },
71
+ [ButtonStates.PRESSED]: {
72
+ backgroundColor: COLORS.NEUTRAL_4,
73
+ borderColor: COLORS.NEUTRAL_5,
74
+ raiseColor: COLORS.NEUTRAL_5,
55
75
  },
56
76
  }}
57
- raiseLevel={5}
58
77
  >
59
78
  <CloseIcon />
60
79
  </Button>
@@ -84,6 +103,10 @@ const styles = StyleSheet.create({
84
103
  buttonClose: {
85
104
  width: 50,
86
105
  height: 50,
106
+ borderRadius: 50,
107
+ paddingHorizontal: 0,
108
+ borderWidth: 1.5,
109
+ borderColor: COLORS.NEUTRAL_5,
87
110
  },
88
111
  buttonTranslate: {
89
112
  alignItems: 'center',
@@ -61,8 +61,19 @@ export class ChatbotModel {
61
61
  .reset(this.resetAlternatives)
62
62
 
63
63
  // TODO: do not pass this, just what you need
64
- this.translation = new ChatbotTranslation(this)
65
- this.t2s = new ChatTextToSpeech(this)
64
+ this.translation = new ChatbotTranslation({
65
+ credits: this.credits,
66
+ $alternatives: this.$alternatives,
67
+ setAlternatives: this.setAlternatives,
68
+ defaultMessages: this.defaultMessages,
69
+ messages: this.messages,
70
+ api: this.api,
71
+ })
72
+
73
+ this.t2s = new ChatTextToSpeech({
74
+ $isOpen: this.$isOpen,
75
+ api: this.api
76
+ })
66
77
 
67
78
  this.sendHelpRequestFx = this.createSendHelpRequestFx()
68
79
  this.initChatReplyWatcher()
@@ -1,10 +1,9 @@
1
- import { ChatbotModel } from './model'
2
- import { restore, createEvent } from 'effector'
1
+ import { restore, createEvent, StoreWritable } from 'effector'
3
2
  import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants'
4
3
  import { AudioProvider, AudioStatus, PlayTextToSpeechProps } from '../types/t2s.types'
4
+ import { ChatbotAPI } from './api'
5
5
 
6
6
  export class ChatTextToSpeech {
7
- private readonly model: ChatbotModel
8
7
  private readonly audioCache: Record<string, string> = {}
9
8
  private audioProvider: AudioProvider | null = null
10
9
 
@@ -13,10 +12,17 @@ export class ChatTextToSpeech {
13
12
  readonly setStatus = createEvent<AudioStatus>()
14
13
  readonly $status = restore(this.setStatus, AudioStatus.STOPPED)
15
14
 
16
- constructor(chatbotModel: ChatbotModel) {
17
- this.model = chatbotModel
15
+ readonly $isOpen: StoreWritable<boolean>
16
+ readonly api: ChatbotAPI
18
17
 
19
- this.model.$isOpen.updates.watch((isOpen) => {
18
+ constructor({
19
+ $isOpen,
20
+ api
21
+ }: any) {
22
+ this.$isOpen = $isOpen
23
+ this.api = api
24
+
25
+ this.$isOpen.updates.watch((isOpen) => {
20
26
  if (!isOpen) this.reset()
21
27
  })
22
28
  }
@@ -60,7 +66,7 @@ export class ChatTextToSpeech {
60
66
  this.setCurrentPlayingId(messageId)
61
67
 
62
68
  if (!audioPath) {
63
- const response = await this.model.api.textToSpeechTextFx({
69
+ const response = await this.api.textToSpeechTextFx({
64
70
  input: { text },
65
71
  voice: config?.voice ?? DEFAULT_VOICE,
66
72
  audioConfig: config?.audioConfig ?? AUDIO_CONFIG,
@@ -1,18 +1,16 @@
1
- import { createEvent, restore, attach, createEffect, type Effect, sample } from 'effector'
2
- import { ChatbotModel } from './model'
1
+ import { createEvent, restore, attach, createEffect, type Effect, sample, type Store } from 'effector'
3
2
 
4
3
  import {
5
4
  TranslateAlternativesFxProps,
6
5
  TranslateBatchFxProps,
7
6
  TranslateMessageFxProps,
8
7
  } from '../types/translation.types'
9
- import { ConversationMessage } from '../types/model.types'
8
+ import { ChatbotModelProps, ConversationMessage } from '../types/model.types'
10
9
  import { GetAlternativesResponse } from '../types/api.types'
11
10
  import { decodeHTMLEntities } from '../helpers'
11
+ import { ChatbotAPI } from './api'
12
12
 
13
13
  export class ChatbotTranslation {
14
- private readonly model: ChatbotModel
15
-
16
14
  readonly setIsTranslated = createEvent<boolean>()
17
15
  readonly $isTranslated = restore(this.setIsTranslated, false)
18
16
 
@@ -23,14 +21,34 @@ export class ChatbotTranslation {
23
21
  GetAlternativesResponse | null
24
22
  >
25
23
 
26
- constructor(chatbotModel: ChatbotModel) {
27
- this.model = chatbotModel
28
-
29
- this.translateAlternativesFx = this.createTranslateAlternativesEffect()
30
- this.translateMessageFx = this.createTranslateMessageEffect()
31
- this.translateBatchFx = this.createTranslateBatchEffect()
32
-
33
- this.initTranslationSamples()
24
+ readonly credits: ChatbotModelProps['credits']
25
+ readonly $alternatives: Store<GetAlternativesResponse | null>
26
+ readonly setAlternatives = createEvent<GetAlternativesResponse | null>()
27
+ readonly defaultMessages: ChatbotModelProps['messages']
28
+ readonly api: ChatbotAPI
29
+ readonly messages: any
30
+
31
+ constructor({
32
+ credits,
33
+ $alternatives,
34
+ setAlternatives,
35
+ defaultMessages,
36
+ messages,
37
+ api,
38
+ }: any) {
39
+ this.credits = credits
40
+ this.$alternatives = $alternatives
41
+ this.setAlternatives = setAlternatives
42
+ this.defaultMessages = defaultMessages
43
+ this.messages = messages
44
+ this.api = api
45
+
46
+ this.translateAlternativesFx = this.createTranslateAlternativesEffect()
47
+ this.translateMessageFx = this.createTranslateMessageEffect()
48
+ // @ts-ignore
49
+ this.translateBatchFx = this.createTranslateBatchEffect()
50
+
51
+ this.initTranslationSamples()
34
52
  }
35
53
 
36
54
  private shouldSkipTranslation(messages: ConversationMessage[]) {
@@ -51,14 +69,14 @@ export class ChatbotTranslation {
51
69
  private initTranslationSamples() {
52
70
  sample({
53
71
  clock: this.translateBatchFx.doneData,
54
- source: [this.model.credits.$assignmentId, this.model.credits.$exerciseId] as const,
72
+ source: [this.credits.$assignmentId, this.credits.$exerciseId] as const,
55
73
  fn: ([assignmentId, exerciseId], translatedMessages) => ({
56
74
  assignmentId,
57
75
  exerciseId,
58
76
  translatedMessages,
59
77
  }),
60
78
  }).watch(({ assignmentId, exerciseId, translatedMessages }) => {
61
- this.model.messages.setField({
79
+ this.messages.setField({
62
80
  entityId: assignmentId,
63
81
  fieldId: exerciseId,
64
82
  messages: translatedMessages,
@@ -68,7 +86,7 @@ export class ChatbotTranslation {
68
86
 
69
87
  private createTranslateAlternativesEffect() {
70
88
  return attach({
71
- source: [this.model.$alternatives],
89
+ source: [this.$alternatives],
72
90
  mapParams: (params: TranslateAlternativesFxProps['params'], [alternatives]) => ({
73
91
  params,
74
92
  alternatives,
@@ -81,7 +99,7 @@ export class ChatbotTranslation {
81
99
 
82
100
  if (hintAlternatives.length) {
83
101
  const hintText = hintAlternatives.map(({ text }) => text)
84
- const response = await this.model.api.translateTextFx({
102
+ const response = await this.api.translateTextFx({
85
103
  text: hintText,
86
104
  targetLanguage: params.targetLanguage,
87
105
  })
@@ -100,7 +118,7 @@ export class ChatbotTranslation {
100
118
 
101
119
  if (defaultAlternatives.length) {
102
120
  const defaultText = defaultAlternatives.map(({ text }) => text)
103
- const response = await this.model.api.translateTextFx({
121
+ const response = await this.api.translateTextFx({
104
122
  text: defaultText,
105
123
  targetLanguage: params.targetLanguage,
106
124
  })
@@ -125,7 +143,7 @@ export class ChatbotTranslation {
125
143
  private createTranslateMessageEffect() {
126
144
  return createEffect(async ({ message, targetLanguage }: TranslateMessageFxProps) => {
127
145
  const optionsText = message.options.map(({ text }) => text)
128
- const response = await this.model.api.translateTextFx({
146
+ const response = await this.api.translateTextFx({
129
147
  text: [message.message, ...optionsText],
130
148
  targetLanguage,
131
149
  })
@@ -147,8 +165,9 @@ export class ChatbotTranslation {
147
165
 
148
166
  private createTranslateBatchEffect() {
149
167
  return attach({
150
- source: [this.model.credits.$assignmentId, this.model.credits.$exerciseId, this.model.messages.$state],
151
- mapParams: (
168
+ source: [this.credits.$assignmentId, this.credits.$exerciseId, this.messages.$state],
169
+ // @ts-ignore
170
+ mapParams: (
152
171
  params: TranslateBatchFxProps['params'],
153
172
  [assignmentId, exerciseId, messages],
154
173
  ) => ({
@@ -166,7 +185,7 @@ export class ChatbotTranslation {
166
185
  }
167
186
 
168
187
  const messagesText = currentMessages.map(({ message }) => message)
169
- const response = await this.model.api.translateTextFx({
188
+ const response = await this.api.translateTextFx({
170
189
  text: messagesText,
171
190
  targetLanguage: params.targetLanguage,
172
191
  })
@@ -176,12 +195,12 @@ export class ChatbotTranslation {
176
195
  ? await this.translateMessageOptions(lastMessage, params.targetLanguage)
177
196
  : undefined
178
197
 
179
- const errorMessageTranslationResponse = await this.model.api.translateTextFx({
180
- text: [this.model.defaultMessages.error.message],
198
+ const errorMessageTranslationResponse = await this.api.translateTextFx({
199
+ text: [this.defaultMessages.error.message],
181
200
  targetLanguage: params.targetLanguage,
182
201
  })
183
202
 
184
- this.model.defaultMessages.error.translatedMessage = decodeHTMLEntities(
203
+ this.defaultMessages.error.translatedMessage = decodeHTMLEntities(
185
204
  errorMessageTranslationResponse.data.translations[0].translatedText,
186
205
  )
187
206
 
@@ -209,12 +228,12 @@ export class ChatbotTranslation {
209
228
  private async translateMessageOptions(message: ConversationMessage, targetLanguage: string) {
210
229
  if (!message?.options?.length) {
211
230
  const translatedAlternatives = await this.translateAlternativesFx({ targetLanguage })
212
- this.model.setAlternatives(translatedAlternatives)
231
+ this.setAlternatives(translatedAlternatives)
213
232
  return
214
233
  }
215
234
 
216
235
  const optionsText = message.options.map(({ text }) => text)
217
- const response = await this.model.api.translateTextFx({
236
+ const response = await this.api.translateTextFx({
218
237
  text: optionsText,
219
238
  targetLanguage,
220
239
  })
@@ -23,7 +23,7 @@ const styles = StyleSheet.create({
23
23
  borderTopLeftRadius: 8,
24
24
  borderTopRightRadius: 8,
25
25
  borderBottomRightRadius: 8,
26
- shadowColor: COLORS.PRIMARY_SHADOW,
26
+ shadowColor: COLORS.NEUTRAL_10,
27
27
  shadowOffset: { width: 0, height: 1 },
28
28
  shadowOpacity: 0.25,
29
29
  shadowRadius: 3,
@@ -38,6 +38,5 @@ const styles = StyleSheet.create({
38
38
  fontWeight: '600',
39
39
  color: COLORS.NEUTRAL_7,
40
40
  padding: 8,
41
- lineHeight: 20,
42
41
  },
43
42
  })
@@ -73,8 +73,12 @@ export const TeacherFeedbackButton = ({
73
73
  size={size === 'large' ? 37 : 26}
74
74
  />
75
75
  {!!unreadCommentsCount && (
76
- <View style={styles.badgeContainer}>
77
- <UnreadMessagesBadge badgeContent={unreadCommentsCount} />
76
+ <View style={size === 'large' ? styles.badgeContainerLarge : styles.badgeContainer}>
77
+ <UnreadMessagesBadge
78
+ badgeContent={unreadCommentsCount}
79
+ textStyle={size === 'large' && { fontSize: 18 }}
80
+ style={size === 'large' && { width: 32, height: 32, borderRadius: 16 }}
81
+ />
78
82
  </View>
79
83
  )}
80
84
  </View>
@@ -107,6 +111,11 @@ const styles = StyleSheet.create({
107
111
  iconContainer: {
108
112
  position: 'relative',
109
113
  },
114
+ badgeContainerLarge: {
115
+ position: 'absolute',
116
+ top: -24,
117
+ right: -24,
118
+ },
110
119
  badgeContainer: {
111
120
  position: 'absolute',
112
121
  top: -17,
@@ -40,7 +40,7 @@ const styles = StyleSheet.create({
40
40
  borderTopLeftRadius: 8,
41
41
  borderTopRightRadius: 8,
42
42
  borderBottomRightRadius: 8,
43
- shadowColor: COLORS.PRIMARY_SHADOW,
43
+ shadowColor: COLORS.NEUTRAL_10,
44
44
  shadowOffset: { width: 0, height: 1 },
45
45
  shadowOpacity: 0.25,
46
46
  shadowRadius: 3,
@@ -1,14 +1,15 @@
1
1
  import React from 'react'
2
- import { Text, View, StyleSheet, Platform, StyleProp, ViewStyle } from 'react-native'
2
+ import { Text, View, StyleSheet, Platform, StyleProp, ViewStyle, TextStyle } from 'react-native'
3
3
  import { COLORS } from '@magmamath/react-native-ui'
4
4
 
5
5
  type UnreadMessagesBadgeProps = {
6
6
  badgeContent?: number
7
7
  withBorder?: boolean
8
8
  style?: StyleProp<ViewStyle>
9
+ textStyle?: StyleProp<TextStyle>
9
10
  }
10
11
 
11
- export const UnreadMessagesBadge = ({ badgeContent, withBorder = false, style }: UnreadMessagesBadgeProps) => {
12
+ export const UnreadMessagesBadge = ({ badgeContent, withBorder = false, style, textStyle }: UnreadMessagesBadgeProps) => {
12
13
  return (
13
14
  <View
14
15
  style={[
@@ -19,7 +20,7 @@ export const UnreadMessagesBadge = ({ badgeContent, withBorder = false, style }:
19
20
  withBorder && (badgeContent ? styles.withBorderSize : styles.withBorderSizeEmpty),
20
21
  ]}
21
22
  >
22
- <Text style={styles.text}>{badgeContent && badgeContent > 99 ? '99+' : badgeContent}</Text>
23
+ <Text style={[styles.text, textStyle]}>{badgeContent && badgeContent > 99 ? '99+' : badgeContent}</Text>
23
24
  </View>
24
25
  )
25
26
  }
@@ -52,8 +53,10 @@ const styles = StyleSheet.create({
52
53
  borderRadius: 5.75,
53
54
  },
54
55
  text: {
56
+ alignItems: 'center',
57
+ justifyContent: 'center',
55
58
  fontSize: 12,
56
- lineHeight: 16,
59
+ textAlign: 'center',
57
60
  fontWeight: '600',
58
61
  fontFamily: Platform.OS === 'web' ? 'Open Sans, sans-serif' : 'OpenSans-SemiBold',
59
62
  color: COLORS.NEUTRAL_1,