@magmamath/students-features 0.6.5-rc.3 → 0.6.5-rc.4
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/gifCelebrations/GifCelebrations.js +2 -1
- package/dist/commonjs/features/gifCelebrations/GifCelebrations.js.map +1 -1
- package/dist/commonjs/features/gifCelebrations/components/Gif.js +17 -11
- package/dist/commonjs/features/gifCelebrations/components/Gif.js.map +1 -1
- package/dist/commonjs/features/gifCelebrations/components/Progress.js.map +1 -1
- package/dist/commonjs/features/gifCelebrations/constants.js +12 -1
- package/dist/commonjs/features/gifCelebrations/constants.js.map +1 -1
- package/dist/commonjs/features/gifCelebrations/helpers.js +21 -27
- package/dist/commonjs/features/gifCelebrations/helpers.js.map +1 -1
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.cache.js +18 -5
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.cache.js.map +1 -1
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.model.js +11 -40
- package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.model.js.map +1 -1
- package/dist/module/features/gifCelebrations/GifCelebrations.js +2 -1
- package/dist/module/features/gifCelebrations/GifCelebrations.js.map +1 -1
- package/dist/module/features/gifCelebrations/components/Gif.js +17 -11
- package/dist/module/features/gifCelebrations/components/Gif.js.map +1 -1
- package/dist/module/features/gifCelebrations/components/Progress.js +1 -2
- package/dist/module/features/gifCelebrations/components/Progress.js.map +1 -1
- package/dist/module/features/gifCelebrations/constants.js +11 -0
- package/dist/module/features/gifCelebrations/constants.js.map +1 -1
- package/dist/module/features/gifCelebrations/helpers.js +19 -25
- package/dist/module/features/gifCelebrations/helpers.js.map +1 -1
- package/dist/module/features/gifCelebrations/model/GifCelebrations.cache.js +19 -6
- package/dist/module/features/gifCelebrations/model/GifCelebrations.cache.js.map +1 -1
- package/dist/module/features/gifCelebrations/model/GifCelebrations.model.js +11 -40
- package/dist/module/features/gifCelebrations/model/GifCelebrations.model.js.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/components/Gif.d.ts +3 -1
- package/dist/typescript/commonjs/features/gifCelebrations/components/Gif.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/components/Progress.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/constants.d.ts +9 -0
- package/dist/typescript/commonjs/features/gifCelebrations/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts +16 -8
- package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.cache.d.ts +11 -1
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.cache.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.model.d.ts +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/types/model.types.d.ts +7 -0
- package/dist/typescript/commonjs/features/gifCelebrations/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/components/Gif.d.ts +3 -1
- package/dist/typescript/module/features/gifCelebrations/components/Gif.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/components/Progress.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/constants.d.ts +9 -0
- package/dist/typescript/module/features/gifCelebrations/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/helpers.d.ts +16 -8
- package/dist/typescript/module/features/gifCelebrations/helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.cache.d.ts +11 -1
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.cache.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.model.d.ts +1 -1
- package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.model.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/types/model.types.d.ts +7 -0
- package/dist/typescript/module/features/gifCelebrations/types/model.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/gifCelebrations/GifCelebrations.tsx +1 -1
- package/src/features/gifCelebrations/components/Gif.tsx +21 -10
- package/src/features/gifCelebrations/components/Progress.tsx +1 -2
- package/src/features/gifCelebrations/constants.ts +11 -0
- package/src/features/gifCelebrations/helpers.ts +28 -33
- package/src/features/gifCelebrations/model/GifCelebrations.cache.ts +33 -14
- package/src/features/gifCelebrations/model/GifCelebrations.model.ts +13 -37
- package/src/features/gifCelebrations/types/model.types.ts +8 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StyleSheet, View, Image } from 'react-native'
|
|
2
2
|
import React, { useLayoutEffect, useState } from 'react'
|
|
3
3
|
import { BORDER_RADIUS, COLORS, SPACING } from '@magmamath/react-native-ui'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'https://media3.giphy.com/media/v1.Y2lkPWZhYjgxNWZhN3lucHRuYjZtMzRiNTZkeXo3NTBrNzIwejcwdXp0Y3g1c2k2ODA2eiZlcD12MV9naWZzX3NlYXJjaCZjdD1n/lCSABZRhMw6pW/giphy.gif'
|
|
4
|
+
import { CustomGetCachePathMethod } from '../types/model.types'
|
|
5
|
+
import { MAX_GIF_SIZE } from '../constants'
|
|
7
6
|
|
|
8
7
|
type GifProps = {
|
|
9
8
|
uri: string
|
|
9
|
+
getCachePathMethod?: CustomGetCachePathMethod
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
type Size = {
|
|
@@ -14,23 +14,35 @@ type Size = {
|
|
|
14
14
|
height: number
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const Gif = ({ uri }: GifProps) => {
|
|
17
|
+
export const Gif = ({ uri, getCachePathMethod }: GifProps) => {
|
|
18
18
|
const [size, setSize] = useState<Size | null>(null)
|
|
19
|
+
const [pathOrUri, setPathOrUri] = useState<string>('')
|
|
19
20
|
|
|
20
21
|
useLayoutEffect(() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const loadImageSize = async () => {
|
|
23
|
+
const path = getCachePathMethod ? (await getCachePathMethod(uri)) || uri : uri
|
|
24
|
+
|
|
25
|
+
Image.getSize(path, (width, height) => {
|
|
26
|
+
setSize({
|
|
27
|
+
width: Math.min(width, MAX_GIF_SIZE.WIDTH),
|
|
28
|
+
height: Math.min(height, MAX_GIF_SIZE.HEIGHT),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
setPathOrUri(path)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
loadImageSize()
|
|
24
36
|
}, [uri])
|
|
25
37
|
|
|
26
38
|
return (
|
|
27
39
|
<View style={styles.backgroundContainer}>
|
|
28
40
|
<View style={styles.container}>
|
|
29
|
-
{size && (
|
|
41
|
+
{size && pathOrUri && (
|
|
30
42
|
<Image
|
|
31
43
|
alt="Funny celebration animated image"
|
|
32
44
|
source={{
|
|
33
|
-
uri,
|
|
45
|
+
uri: pathOrUri,
|
|
34
46
|
}}
|
|
35
47
|
width={size.width}
|
|
36
48
|
height={size.height}
|
|
@@ -55,6 +67,5 @@ const styles = StyleSheet.create({
|
|
|
55
67
|
},
|
|
56
68
|
image: {
|
|
57
69
|
borderRadius: BORDER_RADIUS[100],
|
|
58
|
-
backgroundColor: 'orange',
|
|
59
70
|
},
|
|
60
71
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StyleSheet, View } from 'react-native'
|
|
1
|
+
import { StyleSheet, View, Image } from 'react-native'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import {
|
|
4
4
|
BORDER_RADIUS,
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
Typography,
|
|
9
9
|
} from '@magmamath/react-native-ui'
|
|
10
10
|
import Animated, { useAnimatedStyle, SharedValue, interpolate } from 'react-native-reanimated'
|
|
11
|
-
import { Image } from 'react-native'
|
|
12
11
|
|
|
13
12
|
const MIN_WIDTH_FOR_ONE_DIGIT = 12
|
|
14
13
|
const MIN_WIDTH_FOR_TWO_DIGITS = 15
|
|
@@ -11,3 +11,14 @@ export const CONTENT_CONTAINER = {
|
|
|
11
11
|
|
|
12
12
|
export const ANIMATION_DURATION = 1750
|
|
13
13
|
export const MIN_PROBLEMS_TO_SHOW_GIF = 6
|
|
14
|
+
|
|
15
|
+
export const MAX_GIF_SIZE = {
|
|
16
|
+
WIDTH: 480,
|
|
17
|
+
HEIGHT: 300,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const GROUPS_PERCENTAGES = {
|
|
21
|
+
group1: [15, 20, 25, 30], // Early celebrations
|
|
22
|
+
group2: [33, 40, 45, 50], // Mid celebrations
|
|
23
|
+
group3: [60, 66, 75, 80], // Party
|
|
24
|
+
}
|
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
import { GifsGroups } from './types/model.types'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// We are also going to have different buckets with different gifs. The logic is as follows:
|
|
18
|
-
// Group 1: 15%, 20%, 25%, 30% - Early celebrations
|
|
19
|
-
// Group 2: 33%, 40%, 45%, 50% - Mid celebrations
|
|
20
|
-
// Group 3: 60%, 66%, 75%, 80% - Party
|
|
21
|
-
|
|
22
|
-
export const gifSelect = ({ gifsGroups, resolvedProblem, totalProblems }: GifSelectProps) => {
|
|
23
|
-
if (totalProblems < 7) return null
|
|
24
|
-
|
|
25
|
-
const group = Math.ceil((resolvedProblem / totalProblems) * 100)
|
|
26
|
-
|
|
27
|
-
if (group <= 20) return gifsGroups.group1[Math.floor(Math.random() * gifsGroups.group1.length)]
|
|
28
|
-
if (group <= 40) return gifsGroups.group2[Math.floor(Math.random() * gifsGroups.group2.length)]
|
|
29
|
-
if (group <= 60) return gifsGroups.group3[Math.floor(Math.random() * gifsGroups.group3.length)]
|
|
30
|
-
|
|
31
|
-
return null
|
|
32
|
-
}
|
|
33
|
-
|
|
1
|
+
import { GifsGroups, GifsStructure } from './types/model.types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Number of problems When we show gif
|
|
5
|
+
* <6 Never
|
|
6
|
+
* 7-12 50% completion
|
|
7
|
+
* 13-18 33%, 66% completion
|
|
8
|
+
* 19-24 25%, 50%, 75 completion
|
|
9
|
+
* 25-30 20%, 40%, 60%, 80% completion
|
|
10
|
+
* .>30 15%, 30%, 45%, 60%, 75% completion
|
|
11
|
+
*
|
|
12
|
+
* We are also going to have different buckets with different gifs. The logic is as follows:
|
|
13
|
+
* Group 1: 15%, 20%, 25%, 30% - Early celebrations
|
|
14
|
+
* Group 2: 33%, 40%, 45%, 50% - Mid celebrations
|
|
15
|
+
* Group 3: 60%, 66%, 75%, 80% - Party
|
|
16
|
+
*/
|
|
34
17
|
export const calculatePercentageTable = (totalProblems: number) => {
|
|
35
18
|
if (totalProblems <= 12) return { 50: Math.ceil(totalProblems * 0.5) }
|
|
36
19
|
|
|
@@ -66,3 +49,15 @@ export const calculatePercentageTable = (totalProblems: number) => {
|
|
|
66
49
|
75: Math.ceil(totalProblems * 0.75),
|
|
67
50
|
}
|
|
68
51
|
}
|
|
52
|
+
|
|
53
|
+
export const generateGifsStructure = (gifs: GifsGroups): GifsStructure =>
|
|
54
|
+
Object.fromEntries(
|
|
55
|
+
Object.entries(gifs).map(([key, value]) => [
|
|
56
|
+
key,
|
|
57
|
+
value.map((url) => ({
|
|
58
|
+
url,
|
|
59
|
+
isShown: false,
|
|
60
|
+
group: key as `group${number}`,
|
|
61
|
+
})),
|
|
62
|
+
]),
|
|
63
|
+
)
|
|
@@ -1,24 +1,43 @@
|
|
|
1
|
-
import { createEvent, createStore } from 'effector'
|
|
2
|
-
import {
|
|
1
|
+
import { createEffect, createEvent, createStore } from 'effector'
|
|
2
|
+
import {
|
|
3
|
+
GifsGroups,
|
|
4
|
+
GifsStructure,
|
|
5
|
+
CustomPrefetchMethod,
|
|
6
|
+
CustomGetCachePathMethod,
|
|
7
|
+
} from '../types/model.types'
|
|
8
|
+
import { generateGifsStructure } from '../helpers'
|
|
9
|
+
import { Image } from 'react-native'
|
|
10
|
+
|
|
11
|
+
type GifCelebrationsCacheProps = {
|
|
12
|
+
customPrefetchMethod?: CustomPrefetchMethod
|
|
13
|
+
customGetCachePathMethod?: CustomGetCachePathMethod
|
|
14
|
+
}
|
|
3
15
|
|
|
4
16
|
export class GifCelebrationsCache {
|
|
5
17
|
public readonly initialSet = createEvent<GifsGroups>()
|
|
6
18
|
public readonly set = createEvent<GifsStructure>()
|
|
7
19
|
public readonly reset = createEvent()
|
|
8
20
|
|
|
21
|
+
public readonly prefetchMethod: CustomPrefetchMethod | typeof Image.prefetch
|
|
22
|
+
public readonly getCachePathMethod?: CustomGetCachePathMethod
|
|
23
|
+
|
|
24
|
+
public readonly prefetchGifs = createEffect<GifsGroups, void>((data) => {
|
|
25
|
+
Object.values(data).forEach((group) => {
|
|
26
|
+
group.forEach((gifUrl) => {
|
|
27
|
+
Image.prefetch(gifUrl)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
this.initialSet(data)
|
|
32
|
+
})
|
|
33
|
+
|
|
9
34
|
public readonly $gifs = createStore<GifsStructure | null>(null)
|
|
10
35
|
.reset(this.reset)
|
|
11
|
-
.on(this.initialSet, (_, gifs) =>
|
|
12
|
-
Object.fromEntries(
|
|
13
|
-
Object.entries(gifs).map(([key, value]) => [
|
|
14
|
-
key,
|
|
15
|
-
value.map((url) => ({
|
|
16
|
-
url,
|
|
17
|
-
isShown: false,
|
|
18
|
-
group: key as `group${number}`,
|
|
19
|
-
})),
|
|
20
|
-
]),
|
|
21
|
-
),
|
|
22
|
-
)
|
|
36
|
+
.on(this.initialSet, (_, gifs) => generateGifsStructure(gifs))
|
|
23
37
|
.on(this.set, (_, gifs) => gifs)
|
|
38
|
+
|
|
39
|
+
constructor({ customPrefetchMethod, customGetCachePathMethod }: GifCelebrationsCacheProps) {
|
|
40
|
+
this.prefetchMethod = customPrefetchMethod || Image.prefetch
|
|
41
|
+
this.getCachePathMethod = customGetCachePathMethod
|
|
42
|
+
}
|
|
24
43
|
}
|
|
@@ -3,20 +3,12 @@ import { GifCelebrationsApi } from './GifCelebrationsApi'
|
|
|
3
3
|
import {
|
|
4
4
|
GifCelebrationsModelProps,
|
|
5
5
|
GifObject,
|
|
6
|
-
GifsGroups,
|
|
7
6
|
GifsStructure,
|
|
8
7
|
ProblemsPercentageTable,
|
|
9
8
|
} from '../types/model.types'
|
|
10
9
|
import { GifCelebrationsCache } from './GifCelebrations.cache'
|
|
11
10
|
import { calculatePercentageTable } from '../helpers'
|
|
12
|
-
import {
|
|
13
|
-
import { MIN_PROBLEMS_TO_SHOW_GIF } from '../constants'
|
|
14
|
-
|
|
15
|
-
const GROUPS_PERCENTAGES = {
|
|
16
|
-
group1: [15, 20, 25, 30], // Early celebrations
|
|
17
|
-
group2: [33, 40, 45, 50], // Mid celebrations
|
|
18
|
-
group3: [60, 66, 75, 80], // Party
|
|
19
|
-
}
|
|
11
|
+
import { GROUPS_PERCENTAGES, MIN_PROBLEMS_TO_SHOW_GIF } from '../constants'
|
|
20
12
|
|
|
21
13
|
type HandleGifSelectionProps = {
|
|
22
14
|
gifsGroups: GifsStructure
|
|
@@ -47,9 +39,15 @@ export class GifCelebrationsModel {
|
|
|
47
39
|
public readonly initialize = createEvent()
|
|
48
40
|
public readonly resetGroupGifs = createEvent<string>()
|
|
49
41
|
|
|
50
|
-
constructor({
|
|
42
|
+
constructor({
|
|
43
|
+
api,
|
|
44
|
+
totalProblems,
|
|
45
|
+
resolvedProblems,
|
|
46
|
+
customPrefetchMethod,
|
|
47
|
+
customGetCachePathMethod,
|
|
48
|
+
}: GifCelebrationsModelProps) {
|
|
51
49
|
this.api = new GifCelebrationsApi(api)
|
|
52
|
-
this.cache = new GifCelebrationsCache()
|
|
50
|
+
this.cache = new GifCelebrationsCache({ customPrefetchMethod, customGetCachePathMethod })
|
|
53
51
|
|
|
54
52
|
this.$totalProblems = totalProblems
|
|
55
53
|
this.$resolvedProblems = resolvedProblems
|
|
@@ -60,21 +58,9 @@ export class GifCelebrationsModel {
|
|
|
60
58
|
private setupEventHandlers() {
|
|
61
59
|
sample({
|
|
62
60
|
source: this.api.getGifsFx.doneData,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
: (() => {
|
|
67
|
-
throw new Error('Failed to fetch GIFs')
|
|
68
|
-
})(),
|
|
69
|
-
target: createEffect((data: GifsGroups) => {
|
|
70
|
-
Object.values(data).forEach((group) => {
|
|
71
|
-
group.forEach((gifUrl) => {
|
|
72
|
-
Image.prefetch(gifUrl)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
this.cache.initialSet(data)
|
|
77
|
-
}),
|
|
61
|
+
filter: (response) => response.ok,
|
|
62
|
+
fn: (response) => response.data,
|
|
63
|
+
target: this.cache.prefetchGifs,
|
|
78
64
|
})
|
|
79
65
|
|
|
80
66
|
sample({
|
|
@@ -110,34 +96,28 @@ export class GifCelebrationsModel {
|
|
|
110
96
|
|
|
111
97
|
private readonly handleGifSelection = createEffect(
|
|
112
98
|
({ gifsGroups, resolvedProblem, problemsPercentageTable }: HandleGifSelectionProps) => {
|
|
113
|
-
// Find which percentage milestone this resolved problem represents
|
|
114
99
|
const percentageMilestone = Object.keys(problemsPercentageTable).find(
|
|
115
100
|
(key) => problemsPercentageTable[Number(key)] === resolvedProblem,
|
|
116
101
|
)
|
|
102
|
+
|
|
117
103
|
if (!percentageMilestone) return null
|
|
118
104
|
|
|
119
|
-
// Find which group this percentage belongs to
|
|
120
105
|
const groupName = this.findGroupForPercentage(Number(percentageMilestone)) as
|
|
121
106
|
| `group${number}`
|
|
122
107
|
| undefined
|
|
123
108
|
if (!groupName) return null
|
|
124
109
|
|
|
125
|
-
// Get available gifs for this group
|
|
126
110
|
const gifsForGroup = gifsGroups[groupName]
|
|
127
111
|
if (!gifsForGroup || gifsForGroup.length === 0) return null
|
|
128
112
|
|
|
129
|
-
// Find the first gif that hasn't been shown yet
|
|
130
113
|
const unusedGifIndex = gifsForGroup.findIndex((gif) => !gif.isShown)
|
|
131
114
|
|
|
132
|
-
// If all gifs have been shown, reset the group and start from the beginning
|
|
133
115
|
if (unusedGifIndex === -1) {
|
|
134
|
-
// Reset the group by setting all gifs to isShown: false
|
|
135
116
|
const updatedGifsGroups = { ...gifsGroups }
|
|
136
117
|
updatedGifsGroups[groupName] = gifsGroups[groupName].map((gif) => ({
|
|
137
118
|
...gif,
|
|
138
119
|
isShown: false,
|
|
139
120
|
}))
|
|
140
|
-
// Select the first gif from the group
|
|
141
121
|
const gifObject: GifObject = {
|
|
142
122
|
...updatedGifsGroups[groupName][0],
|
|
143
123
|
isShown: true,
|
|
@@ -145,20 +125,16 @@ export class GifCelebrationsModel {
|
|
|
145
125
|
updatedGifsGroups[groupName][0].isShown = true
|
|
146
126
|
|
|
147
127
|
this.setActiveGif(gifObject)
|
|
148
|
-
// Update the cache with the shown gif
|
|
149
128
|
this.cache.set(updatedGifsGroups)
|
|
150
129
|
}
|
|
151
130
|
|
|
152
|
-
// Otherwise, use the first unused gif
|
|
153
131
|
const selectedGif = gifsForGroup[unusedGifIndex]
|
|
154
132
|
|
|
155
|
-
// Create a new gif object with isShown set to true
|
|
156
133
|
const gifObject: GifObject = {
|
|
157
134
|
...selectedGif,
|
|
158
135
|
isShown: true,
|
|
159
136
|
}
|
|
160
137
|
|
|
161
|
-
// Update the cache with the shown gif
|
|
162
138
|
const updatedGifsGroups = { ...gifsGroups }
|
|
163
139
|
updatedGifsGroups[groupName][unusedGifIndex].isShown = true
|
|
164
140
|
this.cache.set(updatedGifsGroups)
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { Store } from 'effector'
|
|
2
2
|
|
|
3
|
+
export type CustomPrefetchMethod = (gifs: string[] | string) => Promise<unknown>
|
|
4
|
+
export type CustomGetCachePathMethod = (uri: string) => Promise<string | null>
|
|
5
|
+
|
|
3
6
|
export type GifCelebrationApiRequests = {
|
|
4
7
|
getGifs: () => Promise<GifResponse>
|
|
5
8
|
}
|
|
9
|
+
export type GifCelebrationCache = {
|
|
10
|
+
prefetchMethod?: CustomPrefetchMethod
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
export type GifCelebrationsModelProps = {
|
|
8
14
|
api: GifCelebrationApiRequests
|
|
9
15
|
totalProblems: Store<number>
|
|
10
16
|
resolvedProblems: Store<number>
|
|
17
|
+
customPrefetchMethod?: CustomPrefetchMethod
|
|
18
|
+
customGetCachePathMethod?: CustomGetCachePathMethod
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export type GifsGroup = string[]
|