BugFix for incorrect caching of NIP95
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package com.vitorpamplona.amethyst.model
|
package com.vitorpamplona.amethyst.model
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.net.toUri
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import com.vitorpamplona.amethyst.Amethyst
|
import com.vitorpamplona.amethyst.Amethyst
|
||||||
@@ -763,19 +762,18 @@ object LocalCache {
|
|||||||
note.addRelay(relay)
|
note.addRelay(relay)
|
||||||
}
|
}
|
||||||
|
|
||||||
val file = File(Amethyst.instance.applicationContext.externalCacheDir, "NIP95")
|
|
||||||
|
|
||||||
if (!file.exists()) {
|
|
||||||
try {
|
try {
|
||||||
val cachePath = File(Amethyst.instance.applicationContext.externalCacheDir, "NIP95")
|
val cachePath = File(Amethyst.instance.applicationContext.externalCacheDir, "NIP95")
|
||||||
cachePath.mkdirs()
|
cachePath.mkdirs()
|
||||||
val stream = FileOutputStream(File(cachePath, event.id))
|
val file = File(cachePath, event.id)
|
||||||
|
if (!file.exists()) {
|
||||||
|
val stream = FileOutputStream(file)
|
||||||
stream.write(event.decode())
|
stream.write(event.decode())
|
||||||
stream.close()
|
stream.close()
|
||||||
Log.e("EventLogger", "Saved to disk as ${File(cachePath, event.id).toUri()}")
|
// Log.i("FileStorageEvent", "Saved to disk as ${File(cachePath, event.id).toUri()}")
|
||||||
} catch (e: IOException) {
|
|
||||||
Log.e("FileSotrageEvent", "FileStorageEvent save to disk error: " + event.id, e)
|
|
||||||
}
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.e("FileStorageEvent", "FileStorageEvent save to disk error: " + event.id, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already processed this event.
|
// Already processed this event.
|
||||||
|
|||||||
@@ -1657,8 +1657,9 @@ fun FileStorageHeaderDisplay(baseNote: Note) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val noteState = fileNote?.live()?.metadata?.observeAsState()
|
fileNote?.let { fileNote2 ->
|
||||||
val note = noteState?.value?.note
|
val noteState by fileNote2.live().metadata.observeAsState()
|
||||||
|
val note = remember(noteState) { noteState?.note }
|
||||||
|
|
||||||
var content by remember { mutableStateOf<ZoomableContent?>(null) }
|
var content by remember { mutableStateOf<ZoomableContent?>(null) }
|
||||||
|
|
||||||
@@ -1697,6 +1698,7 @@ fun FileStorageHeaderDisplay(baseNote: Note) {
|
|||||||
content?.let {
|
content?.let {
|
||||||
ZoomableContentView(content = it, listOf(it))
|
ZoomableContentView(content = it, listOf(it))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user