mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 15:45:22 +00:00
load notes in background
This commit is contained in:
@@ -532,14 +532,14 @@ private fun ChatDialogs(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Location notes sheet
|
// Location notes sheet - matches iOS pattern exactly
|
||||||
if (showLocationNotesSheet) {
|
if (showLocationNotesSheet) {
|
||||||
val context = androidx.compose.ui.platform.LocalContext.current
|
val context = androidx.compose.ui.platform.LocalContext.current
|
||||||
val locationManager = remember { com.bitchat.android.geohash.LocationChannelManager.getInstance(context) }
|
val locationManager = remember { com.bitchat.android.geohash.LocationChannelManager.getInstance(context) }
|
||||||
val availableChannels by locationManager.availableChannels.observeAsState(emptyList())
|
val availableChannels by locationManager.availableChannels.observeAsState(emptyList())
|
||||||
val nickname by viewModel.nickname.observeAsState("")
|
val nickname by viewModel.nickname.observeAsState("")
|
||||||
|
|
||||||
// Get building-level geohash (precision 8 for iOS compatibility)
|
// iOS pattern: notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash
|
||||||
val buildingGeohash = availableChannels.firstOrNull { it.level == com.bitchat.android.geohash.GeohashChannelLevel.BUILDING }?.geohash
|
val buildingGeohash = availableChannels.firstOrNull { it.level == com.bitchat.android.geohash.GeohashChannelLevel.BUILDING }?.geohash
|
||||||
|
|
||||||
if (buildingGeohash != null) {
|
if (buildingGeohash != null) {
|
||||||
@@ -554,13 +554,8 @@ private fun ChatDialogs(
|
|||||||
nickname = nickname,
|
nickname = nickname,
|
||||||
onDismiss = onLocationNotesSheetDismiss
|
onDismiss = onLocationNotesSheetDismiss
|
||||||
)
|
)
|
||||||
|
|
||||||
// Subscribe to notes counter when sheet is shown
|
|
||||||
LaunchedEffect(buildingGeohash) {
|
|
||||||
com.bitchat.android.nostr.LocationNotesCounter.subscribe(buildingGeohash)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// No block geohash available - show error state
|
// No building geohash available - show error state (matches iOS)
|
||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
onDismissRequest = onLocationNotesSheetDismiss,
|
onDismissRequest = onLocationNotesSheetDismiss,
|
||||||
containerColor = MaterialTheme.colorScheme.surface
|
containerColor = MaterialTheme.colorScheme.surface
|
||||||
|
|||||||
@@ -610,6 +610,7 @@ class ChatViewModel(
|
|||||||
/**
|
/**
|
||||||
* Update notes counter subscription based on current channel and location permission
|
* Update notes counter subscription based on current channel and location permission
|
||||||
* iOS pattern: Subscribe when in mesh mode and location is authorized
|
* iOS pattern: Subscribe when in mesh mode and location is authorized
|
||||||
|
* ENHANCEMENT: Also subscribe LocationNotesManager to load actual notes in background
|
||||||
*/
|
*/
|
||||||
private fun updateNotesCounterSubscription(channel: com.bitchat.android.geohash.ChannelID?) {
|
private fun updateNotesCounterSubscription(channel: com.bitchat.android.geohash.ChannelID?) {
|
||||||
try {
|
try {
|
||||||
@@ -631,20 +632,26 @@ class ChatViewModel(
|
|||||||
|
|
||||||
if (buildingGeohash != null) {
|
if (buildingGeohash != null) {
|
||||||
Log.d(TAG, "📍 Subscribing to location notes for building geohash: $buildingGeohash")
|
Log.d(TAG, "📍 Subscribing to location notes for building geohash: $buildingGeohash")
|
||||||
|
// Subscribe counter for badge
|
||||||
com.bitchat.android.nostr.LocationNotesCounter.subscribe(buildingGeohash)
|
com.bitchat.android.nostr.LocationNotesCounter.subscribe(buildingGeohash)
|
||||||
|
// ALSO subscribe manager to load actual notes in background
|
||||||
|
com.bitchat.android.nostr.LocationNotesManager.getInstance().setGeohash(buildingGeohash)
|
||||||
} else {
|
} else {
|
||||||
// Keep existing subscription if we had one (avoid flicker)
|
// Keep existing subscription if we had one (avoid flicker)
|
||||||
if (com.bitchat.android.nostr.LocationNotesCounter.geohash.value == null) {
|
if (com.bitchat.android.nostr.LocationNotesCounter.geohash.value == null) {
|
||||||
com.bitchat.android.nostr.LocationNotesCounter.cancel()
|
com.bitchat.android.nostr.LocationNotesCounter.cancel()
|
||||||
|
com.bitchat.android.nostr.LocationNotesManager.getInstance().cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
com.bitchat.android.nostr.LocationNotesCounter.cancel()
|
com.bitchat.android.nostr.LocationNotesCounter.cancel()
|
||||||
|
com.bitchat.android.nostr.LocationNotesManager.getInstance().cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is com.bitchat.android.geohash.ChannelID.Location -> {
|
is com.bitchat.android.geohash.ChannelID.Location -> {
|
||||||
// Location channel mode: cancel counter (only show in mesh mode)
|
// Location channel mode: cancel counter (only show in mesh mode)
|
||||||
com.bitchat.android.nostr.LocationNotesCounter.cancel()
|
com.bitchat.android.nostr.LocationNotesCounter.cancel()
|
||||||
|
com.bitchat.android.nostr.LocationNotesManager.getInstance().cancel()
|
||||||
}
|
}
|
||||||
null -> {
|
null -> {
|
||||||
// Default to mesh behavior
|
// Default to mesh behavior
|
||||||
|
|||||||
Reference in New Issue
Block a user