5 Commits
2.3 ... 2.3.2

Author SHA1 Message Date
00569666be Improve delete multiple games in a row.
All checks were successful
Build Android / build (push) Successful in 4m33s
closes #53
2023-11-02 22:32:35 +01:00
2cf6578378 Update gradle. 2023-11-02 22:32:31 +01:00
fbcf9af761 Change deploy user. 2023-11-02 22:32:24 +01:00
1c6674373f Merge branch 'hotfix/2.3.1'
All checks were successful
Build Android / build (push) Successful in 9m21s
2023-10-01 07:45:09 +02:00
67e803f913 Revert "Scroll to top on game activated."
All checks were successful
Build Android / build (push) Successful in 8m44s
This reverts commit fa9786de04.

# Conflicts:
#	app/src/main/java/me/zobrist/tichucounter/ui/history/HistoryView.kt
2023-09-27 22:45:10 +02:00
5 changed files with 43 additions and 30 deletions

View File

@@ -32,13 +32,13 @@ jobs:
- name: Deploy latest to Nextcloud
run: |
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.apk"
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/latest/app-release.aab"
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/latest/app-release.apk"
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/latest/app-release.aab"
- name: Deploy tagged build to Nextcloud
run: |
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.apk"
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "https://nextcloud.zobrist.me/remote.php/dav/files/deploy/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.aab"
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.apk"
curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.aab"
- uses: https://github.com/ravsamhq/notify-slack-action@v2
if: always()

View File

@@ -27,6 +27,8 @@ class GameRepository @Inject constructor(
private val newGameFlow = MutableStateFlow(Game())
private var deletedGame: GameWithScores? = null
init {
CoroutineScope(Dispatchers.IO).launch {
gameDao.getActiveAsFlow().collect {
@@ -104,14 +106,33 @@ class GameRepository @Inject constructor(
withContext(Dispatchers.IO) {
try {
val game = gameDao.getGameById(uid)
gameDao.delete(game)
val rounds = roundDao.getAllForGame(game.uid)
deletedGame = GameWithScores(game, rounds)
gameDao.delete(game)
roundDao.delete(rounds)
} catch (_: NullPointerException) {
}
}
}
suspend fun restoreLastDeletedGame() {
if (deletedGame == null) {
return
}
val revert = deletedGame!!
deletedGame = null
withContext(Dispatchers.IO) {
gameDao.insert(revert.game)
revert.rounds.forEach {
roundDao.insert(it)
}
}
}
suspend fun deleteAllInactive() {
withContext(Dispatchers.IO) {
try {

View File

@@ -53,7 +53,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import me.zobrist.tichucounter.R
import me.zobrist.tichucounter.data.GameWithScores
@@ -96,6 +95,7 @@ fun HistoryList(
viewModel.activateGame(it)
lazyListState.animateScrollToItem(0)
snackbarHostState.currentSnackbarData?.dismiss()
val result = snackbarHostState.showSnackbar(
message = activatedMessage,
actionLabel = activatedActionLabel,
@@ -109,7 +109,9 @@ fun HistoryList(
},
onDeleteClicked = {
scope.launch {
viewModel.markToDelete(it)
viewModel.deleteGame(it)
snackbarHostState.currentSnackbarData?.dismiss()
val result = snackbarHostState.showSnackbar(
message = deletedMessage,
actionLabel = deletedActionLabel,
@@ -119,7 +121,7 @@ fun HistoryList(
if (result == SnackbarResult.Dismissed) {
viewModel.deleteGame(it)
} else {
viewModel.unmarkToDelete(it)
viewModel.restoreLastDeletedGame()
}
}
},
@@ -160,31 +162,23 @@ fun HistoryList(
onDeleteAllClicked: () -> Unit,
lazyListState: LazyListState = LazyListState(),
) {
val scope = rememberCoroutineScope()
Row {
LazyColumn(state = lazyListState) {
items(
items = games,
key = { it.game.uid }) { item ->
if (item.game.active) {
key = { it.hashCode() }) {
if (it.game.active) {
HistoryListItem(
item,
it,
Modifier
.animateItemPlacement()
.padding(2.dp)
)
} else {
DismissibleHistoryListItem(
item,
it,
Modifier.animateItemPlacement(),
{
onOpenClicked(it)
scope.launch {
delay(100)
lazyListState.animateScrollToItem(0)
}
},
onOpenClicked,
onDeleteClicked
)
}

View File

@@ -33,20 +33,18 @@ class HistoryViewModel @Inject constructor(
}
}
fun markToDelete(gameId: Long) {
gameAndHistory = fullList.filter { it.game.uid != gameId }
}
fun unmarkToDelete(gameId: Long) {
gameAndHistory = fullList
}
fun deleteGame(gameId: Long) {
viewModelScope.launch {
gameRepository.deleteGame(gameId)
}
}
fun restoreLastDeletedGame() {
viewModelScope.launch {
gameRepository.restoreLastDeletedGame()
}
}
fun activateGame(gameId: Long) {
viewModelScope.launch {
gameRepository.setActive(gameId)

View File

@@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'com.android.tools.build:gradle:8.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong