Fix db update events
parent
d2c12316d3
commit
8b1121fc62
|
@ -339,13 +339,25 @@ class MainActivity : AppCompatActivity() {
|
|||
// Schedule for resume if not active
|
||||
if (lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED) || force) {
|
||||
mNeedRefresh = false
|
||||
binding.webview.evaluateJavascript(
|
||||
"window._nc_event_bus?.emit('files:file:created')",
|
||||
null
|
||||
)
|
||||
busEmit("nativex:db:updated")
|
||||
busEmit("memories:timeline:soft-refresh")
|
||||
} else {
|
||||
mNeedRefresh = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit an event to the nextcloud event bus
|
||||
*/
|
||||
fun busEmit(event: String, data: String = "null") {
|
||||
runOnUiThread {
|
||||
if (binding.webview.url == null) return@runOnUiThread
|
||||
|
||||
binding.webview.evaluateJavascript(
|
||||
"window._nc_event_bus?.emit('$event', $data)",
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -284,6 +284,9 @@ class TimelineQuery(private val mCtx: MainActivity) {
|
|||
|
||||
// Delete from database
|
||||
mPhotoDao.deleteFileIds(sysImgs.map { it.fileId })
|
||||
|
||||
// Clear UI cache
|
||||
mCtx.busEmit("nativex:db:updated")
|
||||
} finally {
|
||||
synchronized(this) { deleting = false }
|
||||
}
|
||||
|
@ -420,7 +423,7 @@ class TimelineQuery(private val mCtx: MainActivity) {
|
|||
// Delete file with same local_id and insert new one
|
||||
mPhotoDao.deleteFileIds(listOf(fileId))
|
||||
mPhotoDao.insert(photo)
|
||||
Log.v(TAG, "Inserted file to local DB: $fileId / $baseName / $photo")
|
||||
Log.v(TAG, "Inserted file to local DB: $photo")
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue