-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from TimerTiTi/fix-double-toast
Fix double toast
- Loading branch information
Showing
9 changed files
with
96 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...daily/impl/src/main/kotlin/com/titi/app/data/daily/impl/local/datastore/DailyDataStore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.titi.app.data.daily.impl.local.datastore | ||
|
||
import android.content.Context | ||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import androidx.datastore.preferences.preferencesDataStore | ||
import com.titi.app.core.util.readValue | ||
import com.titi.app.core.util.storeValue | ||
|
||
internal class DailyDataStore(context: Context) { | ||
private val dataStore: DataStore<Preferences> = context.dataStore | ||
|
||
suspend fun setResetDailyEvent(daily: String) { | ||
dataStore.storeValue(DAILY_RESET__KEY, daily) | ||
} | ||
|
||
suspend fun getResetDailyEvent(): String? = dataStore.readValue(DAILY_RESET__KEY) | ||
|
||
companion object { | ||
private const val DAILY_RESET_PREF_NAME = "dailyPrefName" | ||
private val DAILY_RESET__KEY = stringPreferencesKey("dailyKey") | ||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore( | ||
name = DAILY_RESET_PREF_NAME, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
domain/daily/src/main/kotlin/com/titi/app/doamin/daily/usecase/GetResetDailyEventUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.titi.app.doamin.daily.usecase | ||
|
||
import com.titi.app.core.util.getDailyDayWithHour | ||
import com.titi.app.data.daily.api.DailyRepository | ||
import javax.inject.Inject | ||
|
||
class GetResetDailyEventUseCase @Inject constructor( | ||
private val dailyRepository: DailyRepository, | ||
) { | ||
suspend operator fun invoke(): Boolean { | ||
val resetDaily = dailyRepository.getResetDailyEvent() | ||
val today = getDailyDayWithHour(6).first | ||
|
||
return if (resetDaily != null) { | ||
if (resetDaily != today) { | ||
dailyRepository.setResetDailyEvent(today) | ||
true | ||
} else { | ||
false | ||
} | ||
} else { | ||
dailyRepository.setResetDailyEvent(today) | ||
true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters