Skip to content

Commit

Permalink
Merge pull request #224 from wafflestudio/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
davin111 authored Feb 3, 2024
2 parents 4b809a5 + 1649592 commit 4e6a06d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/main/kotlin/timetables/dto/TimetableThemeDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data class TimetableThemeDto(
fun TimetableThemeDto(timetableTheme: TimetableTheme) =
with(timetableTheme) {
TimetableThemeDto(
id = id,
id = if (isCustom) id else null,
theme = toBasicThemeType(),
name = name,
colors = colors,
Expand Down
23 changes: 19 additions & 4 deletions core/src/main/kotlin/timetables/service/TimetableThemeService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ class TimetableThemeServiceImpl(
val customThemes = timetableThemeRepository.findByUserIdAndIsCustomTrueOrderByCreatedAtDesc(userId)
val defaultTheme = getDefaultTheme(userId)

return (
BasicThemeType.values().map { buildTimetableTheme(userId, it, isDefault = it.displayName == defaultTheme?.name) } +
customThemes
val basicThemes = BasicThemeType.values().map {
buildTimetableTheme(
userId,
it,
isDefault = (
it.displayName == defaultTheme?.name ||
(defaultTheme == null && it == BasicThemeType.SNUTT)
)
)
}

return basicThemes + customThemes
}

override suspend fun addTheme(userId: String, name: String, colors: List<ColorSet>): TimetableTheme {
Expand Down Expand Up @@ -194,7 +202,14 @@ class TimetableThemeServiceImpl(

return themeId?.let {
timetableThemeRepository.findByIdAndUserId(it, userId) ?: throw ThemeNotFoundException
} ?: buildTimetableTheme(userId, basicThemeType!!, isDefault = basicThemeType.displayName == defaultTheme?.name)
} ?: buildTimetableTheme(
userId,
basicThemeType!!,
isDefault = (
basicThemeType.displayName == defaultTheme?.name ||
(defaultTheme == null && basicThemeType == BasicThemeType.SNUTT)
),
)
}

private suspend fun getCustomTheme(userId: String, themeId: String): TimetableTheme {
Expand Down

0 comments on commit 4e6a06d

Please sign in to comment.