Commit cd41c1f
committed
refactor(core): improve caching and profile data mapping
This commit refines the caching mechanism and data layer for user profiles and repository details. It consolidates cache time-to-live constants, improves cache invalidation logic, and introduces proper DTO-to-domain mapping for GitHub user profiles.
- **refactor(core)**: Moved `CacheTtl` constants into a companion object within `CacheManager` and updated `HOME_REPOS` TTL to 12 hours.
- **fix(core)**: Updated `CacheManager` to use explicit key filtering during `invalidateByPrefix` and `cleanupExpired` to avoid potential `ConcurrentModificationException`.
- **feat(profile)**: Added `UserProfileMappers.kt` and updated `ProfileViewModel` to properly manage user profile fetch jobs, preventing race conditions.
- **feat(details)**: Introduced `GithubUserProfileDto` and associated mapper to separate network and domain models.
- **fix(details)**: Enhanced `DetailsRepositoryImpl` with better error handling, falling back to stale cache data on network failures for repository and profile lookups.
- **feat(ui)**: Updated `AccountSection` to display real stats (repos, followers, following) and improved name display logic.
- **chore**: Removed unnecessary `@Serializable` annotations from domain models.1 parent faf0483 commit cd41c1f
12 files changed
Lines changed: 139 additions & 57 deletions
File tree
- core
- data/src/commonMain/kotlin/zed/rainxch/core/data/cache
- domain/src/commonMain/kotlin/zed/rainxch/core/domain/model
- feature
- details/data/src/commonMain/kotlin/zed/rainxch/details/data
- mappers
- model
- repository
- home/data/src/commonMain/kotlin/zed/rainxch/home/data/repository
- profile
- data/src/commonMain/kotlin/zed/rainxch/profile/data
- mappers
- repository
- presentation/src/commonMain/kotlin/zed/rainxch/profile/presentation
- components/sections
- search/data/src/commonMain/kotlin/zed/rainxch/search/data/repository
Lines changed: 16 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 10 | | |
21 | 11 | | |
22 | 12 | | |
| |||
90 | 80 | | |
91 | 81 | | |
92 | 82 | | |
93 | | - | |
| 83 | + | |
| 84 | + | |
94 | 85 | | |
95 | 86 | | |
96 | 87 | | |
97 | 88 | | |
98 | 89 | | |
99 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
100 | 94 | | |
101 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
102 | 106 | | |
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 3 | | |
7 | 4 | | |
8 | 5 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 3 | | |
7 | 4 | | |
8 | 5 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
Lines changed: 38 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
82 | 97 | | |
83 | | - | |
| 98 | + | |
| 99 | + | |
84 | 100 | | |
85 | | - | |
86 | | - | |
87 | 101 | | |
88 | 102 | | |
89 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
90 | 107 | | |
91 | 108 | | |
92 | 109 | | |
| |||
101 | 118 | | |
102 | 119 | | |
103 | 120 | | |
104 | | - | |
| 121 | + | |
105 | 122 | | |
106 | 123 | | |
107 | 124 | | |
| |||
142 | 159 | | |
143 | 160 | | |
144 | 161 | | |
145 | | - | |
| 162 | + | |
146 | 163 | | |
147 | 164 | | |
148 | 165 | | |
| |||
185 | 202 | | |
186 | 203 | | |
187 | 204 | | |
188 | | - | |
| 205 | + | |
189 | 206 | | |
190 | 207 | | |
191 | 208 | | |
| |||
237 | 254 | | |
238 | 255 | | |
239 | 256 | | |
240 | | - | |
| 257 | + | |
241 | 258 | | |
242 | 259 | | |
243 | 260 | | |
| |||
388 | 405 | | |
389 | 406 | | |
390 | 407 | | |
391 | | - | |
| 408 | + | |
392 | 409 | | |
393 | 410 | | |
394 | 411 | | |
| |||
402 | 419 | | |
403 | 420 | | |
404 | 421 | | |
405 | | - | |
| 422 | + | |
406 | 423 | | |
407 | | - | |
| 424 | + | |
408 | 425 | | |
409 | 426 | | |
410 | 427 | | |
| |||
414 | 431 | | |
415 | 432 | | |
416 | 433 | | |
417 | | - | |
| 434 | + | |
418 | 435 | | |
419 | 436 | | |
420 | 437 | | |
| |||
428 | 445 | | |
429 | 446 | | |
430 | 447 | | |
431 | | - | |
| 448 | + | |
432 | 449 | | |
433 | | - | |
| 450 | + | |
434 | 451 | | |
435 | 452 | | |
436 | | - | |
| 453 | + | |
437 | 454 | | |
438 | | - | |
| 455 | + | |
439 | 456 | | |
440 | 457 | | |
441 | 458 | | |
| |||
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| |||
0 commit comments