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>> {
|
suspend fun refreshMemos(): ApiResult<List<Memo>> {
|
||||||
nextPageToken = ""
|
nextPageToken = ""
|
||||||
hasMorePages = true
|
hasMorePages = true
|
||||||
return when (val result = apiClient.listMemos(pageSize = 50)) {
|
val allFetched = mutableListOf<Memo>()
|
||||||
is ApiResult.Success -> {
|
|
||||||
val memos = result.data.memos.map { it.toDomain() }
|
var token = ""
|
||||||
val now = nowMillis()
|
do {
|
||||||
lastFetchTime = now
|
val result = apiClient.listMemos(pageSize = 50, pageToken = token)
|
||||||
memoDao.upsertAll(memos.map { it.toEntity(now) })
|
when (result) {
|
||||||
nextPageToken = result.data.nextPageToken
|
is ApiResult.Success -> {
|
||||||
hasMorePages = nextPageToken.isNotEmpty()
|
allFetched.addAll(result.data.memos.map { it.toDomain() })
|
||||||
ApiResult.Success(memos)
|
token = result.data.nextPageToken
|
||||||
|
}
|
||||||
|
is ApiResult.Error -> return result
|
||||||
|
is ApiResult.NetworkError -> return result
|
||||||
}
|
}
|
||||||
is ApiResult.Error -> result
|
} while (token.isNotEmpty())
|
||||||
is ApiResult.NetworkError -> result
|
|
||||||
}
|
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>> {
|
suspend fun loadNextPage(): ApiResult<List<Memo>> {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ fun MemoCard(
|
|||||||
onDismissRequest = { showDeleteDialog = false },
|
onDismissRequest = { showDeleteDialog = false },
|
||||||
title = { Text("delete memo?", color = textColor) },
|
title = { Text("delete memo?", color = textColor) },
|
||||||
text = { Text("this cannot be undone.", color = subtleColor) },
|
text = { Text("this cannot be undone.", color = subtleColor) },
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = { showDeleteDialog = false; onDelete?.invoke() }) {
|
TextButton(onClick = { showDeleteDialog = false; onDelete?.invoke() }) {
|
||||||
Text("delete", color = MaterialTheme.colorScheme.error)
|
Text("delete", color = MaterialTheme.colorScheme.error)
|
||||||
@@ -90,7 +90,7 @@ fun MemoCard(
|
|||||||
if (showMenu) {
|
if (showMenu) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showMenu = false },
|
onDismissRequest = { showMenu = false },
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||||
title = null,
|
title = null,
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
@@ -216,7 +216,7 @@ private fun InlineEditor(
|
|||||||
Text(visibility.name.lowercase(), fontSize = 13.sp, color = subtleColor, modifier = Modifier.clickable { showVisibilityMenu = true })
|
Text(visibility.name.lowercase(), fontSize = 13.sp, color = subtleColor, modifier = Modifier.clickable { showVisibilityMenu = true })
|
||||||
if (showVisibilityMenu) {
|
if (showVisibilityMenu) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showVisibilityMenu = false }, containerColor = MaterialTheme.colorScheme.surface, title = null,
|
onDismissRequest = { showVisibilityMenu = false }, containerColor = MaterialTheme.colorScheme.surfaceContainer, title = null,
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
MemoVisibility.entries.forEach { vis ->
|
MemoVisibility.entries.forEach { vis ->
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ fun MemoListScreen(
|
|||||||
if (showVisibilityPicker) {
|
if (showVisibilityPicker) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showVisibilityPicker = false },
|
onDismissRequest = { showVisibilityPicker = false },
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||||
title = null,
|
title = null,
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
@@ -188,7 +188,7 @@ fun MemoListScreen(
|
|||||||
if (showInsertMenu) {
|
if (showInsertMenu) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showInsertMenu = false },
|
onDismissRequest = { showInsertMenu = false },
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||||
title = null,
|
title = null,
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ fun TaskDetailSheet(
|
|||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||||
title = null,
|
title = null,
|
||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
|
|||||||
@@ -84,17 +84,19 @@ fun metroColorScheme(theme: MetroTheme, accent: Color): ColorScheme = when (them
|
|||||||
MetroTheme.AMOLED -> darkColorScheme(
|
MetroTheme.AMOLED -> darkColorScheme(
|
||||||
background = Color.Black,
|
background = Color.Black,
|
||||||
onBackground = Color.White,
|
onBackground = Color.White,
|
||||||
surface = Color.Black,
|
surface = Color(0xFF161616),
|
||||||
onSurface = Color.White,
|
onSurface = Color.White,
|
||||||
surfaceVariant = Color(0xFF111111),
|
surfaceVariant = Color(0xFF1A1A1A),
|
||||||
onSurfaceVariant = Color(0xFF999999),
|
onSurfaceVariant = Color(0xFF999999),
|
||||||
|
surfaceContainer = Color(0xFF1E1E1E),
|
||||||
|
surfaceContainerHigh = Color(0xFF222222),
|
||||||
primary = accent,
|
primary = accent,
|
||||||
onPrimary = Color.White,
|
onPrimary = Color.White,
|
||||||
secondary = Color(0xFF1A1A1A),
|
secondary = Color(0xFF1A1A1A),
|
||||||
onSecondary = Color(0xFFCCCCCC),
|
onSecondary = Color(0xFFCCCCCC),
|
||||||
error = Color(0xFFE51400),
|
error = Color(0xFFE51400),
|
||||||
onError = Color.White,
|
onError = Color.White,
|
||||||
outline = Color(0xFF555555),
|
outline = Color(0xFF444444),
|
||||||
outlineVariant = Color(0xFF333333),
|
outlineVariant = Color(0xFF333333),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user