Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
678 changes: 678 additions & 0 deletions CODE_REVIEW.md

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(na
actual class PlatformStorage(private val context: Context) {

actual suspend fun saveString(key: String, value: String) {
try {
val dataStoreKey = stringPreferencesKey(key)
withTimeout(5000) { // 5 second timeout
context.dataStore.edit { preferences ->
preferences[dataStoreKey] = value
}
val dataStoreKey = stringPreferencesKey(key)
withTimeout(5000) { // 5 second timeout
context.dataStore.edit { preferences ->
preferences[dataStoreKey] = value
}
} catch (e: Exception) {
throw e
}
}

Expand All @@ -43,15 +39,11 @@ actual class PlatformStorage(private val context: Context) {
}

actual suspend fun saveLong(key: String, value: Long) {
try {
val dataStoreKey = longPreferencesKey(key)
withTimeout(5000) { // 5 second timeout
context.dataStore.edit { preferences ->
preferences[dataStoreKey] = value
}
val dataStoreKey = longPreferencesKey(key)
withTimeout(5000) { // 5 second timeout
context.dataStore.edit { preferences ->
preferences[dataStoreKey] = value
}
} catch (e: Exception) {
throw e
}
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ data class TimerState(
val games: List<Game> = emptyList(),
val activeGameId: String? = null,
val settings: SettingsState = SettingsState(),
val selectedType: String = "Preparation", // Deprecated
val selectedPhase: String = "Setup", // New
val selectedPlayer: String = "Everyone", // New
val selectedPhase: String = "Setup", // Current phase selection
val selectedPlayer: String = "Everyone", // Current player selection
val customTypes: List<String> = emptyList(),
val playerTypes: List<String> = emptyList()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ class RoundTimerStorage(
*/
suspend fun saveRounds(rounds: List<Round>) {
try {
cachedRounds = rounds
val jsonString = json.encodeToString(rounds)
platformStorage.saveString(ROUNDS_KEY, jsonString)
cachedRounds = rounds
} catch (e: Exception) {
// Keep cached data even if persistence fails
cachedRounds = rounds
throw StorageException("Failed to save rounds", e)
}
}
Expand Down Expand Up @@ -190,6 +189,10 @@ class RoundTimerStorage(
try {
cachedRounds = emptyList()
platformStorage.remove(ROUNDS_KEY)
platformStorage.remove(GAMES_KEY)
platformStorage.remove(CONFIGURED_TIME_KEY)
platformStorage.remove(ACTIVE_GAME_ID_KEY)
platformStorage.remove(SETTINGS_KEY)
} catch (e: Exception) {
throw StorageException("Failed to clear storage", e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class TimerViewModel : ViewModel() {
)
analyticsService.logEvent(
"timer_started", mapOf(
"game_id" to currentState.activeGameId!!,
"game_id" to (currentState.activeGameId ?: ""),
"configured_time" to currentState.configuredTime.toString(),
"subtle_drumming" to currentState.settings.isSubtleDrummingEnabled.toString(),
"intense_drumming" to currentState.settings.isIntenseDrummingEnabled.toString(),
Expand Down Expand Up @@ -357,7 +357,7 @@ class TimerViewModel : ViewModel() {
deletedRound = currentState.rounds.find { it.id == roundId }
val newRounds = currentState.rounds.filter { it.id != roundId }
_state.value = currentState.copy(rounds = newRounds)
analyticsService.logEvent("round_deleted", mapOf("round_id" to roundId, "game_id" to currentState.activeGameId!!))
analyticsService.logEvent("round_deleted", mapOf("round_id" to roundId, "game_id" to (currentState.activeGameId ?: "")))
viewModelScope.launch {
try {
storage.saveRounds(newRounds)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ actual class SoundPlayer {
actual fun stopSound() {
player?.stop()
}

actual fun cleanup() {
player?.stop()
player = null
}
}

actual fun getSoundPlayer(): SoundPlayer = SoundPlayer()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ actual class SoundPlayer {
actual fun stopSound() {
audio?.pause()
}

actual fun cleanup() {
audio?.pause()
audio = null
}
}

actual fun getSoundPlayer(): SoundPlayer = SoundPlayer()

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ actual class SoundPlayer {
actual fun stopSound() {
audio?.pause()
}

actual fun cleanup() {
audio?.pause()
audio = null
}
}

actual fun getSoundPlayer(): SoundPlayer = SoundPlayer()