mirror of
https://github.com/avinal/nikki.git
synced 2026-07-03 21:40:09 +05:30
Fix pull-to-refresh cache sync and AMOLED dialog visibility
Refresh now does a full sync: - Fetches ALL pages from the API (loops until nextPageToken is empty) - Clears the entire local cache before inserting fresh data - Deleted/archived memos on server are now properly removed locally AMOLED theme dialog fix: - surface raised from #000000 to #161616 (dialogs no longer invisible) - surfaceContainer at #1E1E1E for popup/dialog backgrounds - surfaceContainerHigh at #222222 for elevated surfaces - outline brightened to #444444 for better border visibility - All AlertDialog containerColor changed to surfaceContainer Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
@@ -52,19 +52,28 @@ class MemoRepository(
|
||||
suspend fun refreshMemos(): ApiResult<List<Memo>> {
|
||||
nextPageToken = ""
|
||||
hasMorePages = true
|
||||
return when (val result = apiClient.listMemos(pageSize = 50)) {
|
||||
is ApiResult.Success -> {
|
||||
val memos = result.data.memos.map { it.toDomain() }
|
||||
val now = nowMillis()
|
||||
lastFetchTime = now
|
||||
memoDao.upsertAll(memos.map { it.toEntity(now) })
|
||||
nextPageToken = result.data.nextPageToken
|
||||
hasMorePages = nextPageToken.isNotEmpty()
|
||||
ApiResult.Success(memos)
|
||||
val allFetched = mutableListOf<Memo>()
|
||||
|
||||
var token = ""
|
||||
do {
|
||||
val result = apiClient.listMemos(pageSize = 50, pageToken = token)
|
||||
when (result) {
|
||||
is ApiResult.Success -> {
|
||||
allFetched.addAll(result.data.memos.map { it.toDomain() })
|
||||
token = result.data.nextPageToken
|
||||
}
|
||||
is ApiResult.Error -> return result
|
||||
is ApiResult.NetworkError -> return result
|
||||
}
|
||||
is ApiResult.Error -> result
|
||||
is ApiResult.NetworkError -> result
|
||||
}
|
||||
} while (token.isNotEmpty())
|
||||
|
||||
val now = nowMillis()
|
||||
lastFetchTime = now
|
||||
memoDao.deleteAll()
|
||||
memoDao.upsertAll(allFetched.map { it.toEntity(now) })
|
||||
nextPageToken = ""
|
||||
hasMorePages = false
|
||||
return ApiResult.Success(allFetched)
|
||||
}
|
||||
|
||||
suspend fun loadNextPage(): ApiResult<List<Memo>> {
|
||||
|
||||
@@ -75,7 +75,7 @@ fun MemoCard(
|
||||
onDismissRequest = { showDeleteDialog = false },
|
||||
title = { Text("delete memo?", color = textColor) },
|
||||
text = { Text("this cannot be undone.", color = subtleColor) },
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||
confirmButton = {
|
||||
TextButton(onClick = { showDeleteDialog = false; onDelete?.invoke() }) {
|
||||
Text("delete", color = MaterialTheme.colorScheme.error)
|
||||
@@ -90,7 +90,7 @@ fun MemoCard(
|
||||
if (showMenu) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showMenu = false },
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||
title = null,
|
||||
text = {
|
||||
Column {
|
||||
@@ -216,7 +216,7 @@ private fun InlineEditor(
|
||||
Text(visibility.name.lowercase(), fontSize = 13.sp, color = subtleColor, modifier = Modifier.clickable { showVisibilityMenu = true })
|
||||
if (showVisibilityMenu) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showVisibilityMenu = false }, containerColor = MaterialTheme.colorScheme.surface, title = null,
|
||||
onDismissRequest = { showVisibilityMenu = false }, containerColor = MaterialTheme.colorScheme.surfaceContainer, title = null,
|
||||
text = {
|
||||
Column {
|
||||
MemoVisibility.entries.forEach { vis ->
|
||||
|
||||
@@ -134,7 +134,7 @@ fun MemoListScreen(
|
||||
if (showVisibilityPicker) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showVisibilityPicker = false },
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||
title = null,
|
||||
text = {
|
||||
Column {
|
||||
@@ -188,7 +188,7 @@ fun MemoListScreen(
|
||||
if (showInsertMenu) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showInsertMenu = false },
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||
title = null,
|
||||
text = {
|
||||
Column {
|
||||
|
||||
@@ -43,7 +43,7 @@ fun TaskDetailSheet(
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||
title = null,
|
||||
text = {
|
||||
Column {
|
||||
|
||||
@@ -84,17 +84,19 @@ fun metroColorScheme(theme: MetroTheme, accent: Color): ColorScheme = when (them
|
||||
MetroTheme.AMOLED -> darkColorScheme(
|
||||
background = Color.Black,
|
||||
onBackground = Color.White,
|
||||
surface = Color.Black,
|
||||
surface = Color(0xFF161616),
|
||||
onSurface = Color.White,
|
||||
surfaceVariant = Color(0xFF111111),
|
||||
surfaceVariant = Color(0xFF1A1A1A),
|
||||
onSurfaceVariant = Color(0xFF999999),
|
||||
surfaceContainer = Color(0xFF1E1E1E),
|
||||
surfaceContainerHigh = Color(0xFF222222),
|
||||
primary = accent,
|
||||
onPrimary = Color.White,
|
||||
secondary = Color(0xFF1A1A1A),
|
||||
onSecondary = Color(0xFFCCCCCC),
|
||||
error = Color(0xFFE51400),
|
||||
onError = Color.White,
|
||||
outline = Color(0xFF555555),
|
||||
outline = Color(0xFF444444),
|
||||
outlineVariant = Color(0xFF333333),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user