Remove unneeded live data

This commit is contained in:
Jackson Harper 2023-05-10 14:48:59 +08:00
parent de3db625f7
commit 711a1cd32c
2 changed files with 6 additions and 6 deletions

View file

@ -130,7 +130,6 @@ fun WebReaderLoadingContainer(slug: String? = null, requestID: String? = null,
val currentTheme = Themes.values().find { it.themeKey == currentThemeKey.value }
val webReaderParams: WebReaderParams? by webReaderViewModel.webReaderParamsLiveData.observeAsState(null)
val annotation: String? by webReaderViewModel.annotationLiveData.observeAsState(null)
val shouldPopView: Boolean by webReaderViewModel.shouldPopViewLiveData.observeAsState(false)
val toolbarHeightPx: Float by webReaderViewModel.currentToolbarHeightLiveData.observeAsState(0.0f)
@ -227,7 +226,7 @@ fun WebReaderLoadingContainer(slug: String? = null, requestID: String? = null,
}
}
BottomSheetState.HIGHLIGHTNOTE -> {
annotation?.let { annotation ->
webReaderViewModel.annotation?.let { annotation ->
BottomSheetUI(title = "Note") {
AnnotationEditView(
initialAnnotation = annotation,

View file

@ -59,7 +59,7 @@ class WebReaderViewModel @Inject constructor(
var maxToolbarHeightPx = 0.0f
val webReaderParamsLiveData = MutableLiveData<WebReaderParams?>(null)
val annotationLiveData = MutableLiveData<String?>(null)
var annotation: String? = null
val javascriptActionLoopUUIDLiveData = MutableLiveData(lastJavascriptActionLoopUUID)
val shouldPopViewLiveData = MutableLiveData(false)
val hasFetchError = MutableLiveData(false)
@ -237,10 +237,10 @@ class WebReaderViewModel @Inject constructor(
}
"annotate" -> {
viewModelScope.launch {
val annotation = Gson()
val annotationStr = Gson()
.fromJson(jsonString, AnnotationWebViewMessage::class.java)
.annotation ?: ""
annotationLiveData.value = annotation
annotation = annotationStr
bottomSheetStateLiveData.postValue(BottomSheetState.HIGHLIGHTNOTE)
}
}
@ -270,7 +270,8 @@ class WebReaderViewModel @Inject constructor(
}
fun cancelAnnotationEdit() {
annotationLiveData.value = null
annotation = null
resetBottomSheet()
}
private fun enqueueScript(javascript: String) {