Commit ·
5386e62
1
Parent(s): b845d45
feature(#137): fix error to parse incorrectly sometimes from fireabase realtime data to autotask model
Browse files
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/fragments/ChatMainFragment.kt
CHANGED
|
@@ -498,7 +498,6 @@ class ChatMainFragment : Fragment(), OnClickListener {
|
|
| 498 |
).observe(viewLifecycleOwner) { resource ->
|
| 499 |
when (resource) {
|
| 500 |
is ApiResource.Loading -> {
|
| 501 |
-
showLoading(true)
|
| 502 |
resource.data?.let { data ->
|
| 503 |
if(data.result == null) {
|
| 504 |
data.thoughts?.let { thoughts ->
|
|
@@ -517,12 +516,10 @@ class ChatMainFragment : Fragment(), OnClickListener {
|
|
| 517 |
}
|
| 518 |
|
| 519 |
is ApiResource.Success -> {
|
| 520 |
-
|
| 521 |
}
|
| 522 |
|
| 523 |
is ApiResource.Error -> {
|
| 524 |
-
showLoading(false)
|
| 525 |
-
addErrorMessage(resource.message!!)
|
| 526 |
}
|
| 527 |
}
|
| 528 |
}
|
|
|
|
| 498 |
).observe(viewLifecycleOwner) { resource ->
|
| 499 |
when (resource) {
|
| 500 |
is ApiResource.Loading -> {
|
|
|
|
| 501 |
resource.data?.let { data ->
|
| 502 |
if(data.result == null) {
|
| 503 |
data.thoughts?.let { thoughts ->
|
|
|
|
| 516 |
}
|
| 517 |
|
| 518 |
is ApiResource.Success -> {
|
| 519 |
+
addMessage(TYPE_CHAT_RECEIVE, "Task is finished.")
|
| 520 |
}
|
| 521 |
|
| 522 |
is ApiResource.Error -> {
|
|
|
|
|
|
|
| 523 |
}
|
| 524 |
}
|
| 525 |
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/viewmodel/ChatViewModel.kt
CHANGED
|
@@ -251,9 +251,6 @@ class ChatViewModel : ViewModel() {
|
|
| 251 |
database.getReference(referencePath).addChildEventListener(object : ChildEventListener {
|
| 252 |
override fun onChildAdded(snapshot: DataSnapshot, previousChildName: String?) {
|
| 253 |
if (snapshot.exists()) {
|
| 254 |
-
if(snapshot.value == null){
|
| 255 |
-
return;
|
| 256 |
-
}
|
| 257 |
try {
|
| 258 |
val data = snapshot.getValue<AutoTaskModel>()
|
| 259 |
data?.let {
|
|
@@ -264,6 +261,9 @@ class ChatViewModel : ViewModel() {
|
|
| 264 |
resource.value = ApiResource.Loading(data)
|
| 265 |
}
|
| 266 |
}
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
}
|
| 269 |
} catch (exception: Exception) {
|
|
@@ -277,9 +277,6 @@ class ChatViewModel : ViewModel() {
|
|
| 277 |
) {
|
| 278 |
if (snapshot.exists()) {
|
| 279 |
try {
|
| 280 |
-
if(snapshot.value == null){
|
| 281 |
-
return;
|
| 282 |
-
}
|
| 283 |
val data = snapshot.getValue<AutoTaskModel>()
|
| 284 |
data?.let {
|
| 285 |
data.command?.let { command ->
|
|
@@ -289,6 +286,9 @@ class ChatViewModel : ViewModel() {
|
|
| 289 |
resource.value = ApiResource.Loading(data)
|
| 290 |
}
|
| 291 |
}
|
|
|
|
|
|
|
|
|
|
| 292 |
}
|
| 293 |
} catch (exception: Exception) {
|
| 294 |
resource.value = ApiResource.Error(exception.toString())
|
|
|
|
| 251 |
database.getReference(referencePath).addChildEventListener(object : ChildEventListener {
|
| 252 |
override fun onChildAdded(snapshot: DataSnapshot, previousChildName: String?) {
|
| 253 |
if (snapshot.exists()) {
|
|
|
|
|
|
|
|
|
|
| 254 |
try {
|
| 255 |
val data = snapshot.getValue<AutoTaskModel>()
|
| 256 |
data?.let {
|
|
|
|
| 261 |
resource.value = ApiResource.Loading(data)
|
| 262 |
}
|
| 263 |
}
|
| 264 |
+
data.result?.let {
|
| 265 |
+
resource.value = ApiResource.Loading(data)
|
| 266 |
+
}
|
| 267 |
|
| 268 |
}
|
| 269 |
} catch (exception: Exception) {
|
|
|
|
| 277 |
) {
|
| 278 |
if (snapshot.exists()) {
|
| 279 |
try {
|
|
|
|
|
|
|
|
|
|
| 280 |
val data = snapshot.getValue<AutoTaskModel>()
|
| 281 |
data?.let {
|
| 282 |
data.command?.let { command ->
|
|
|
|
| 286 |
resource.value = ApiResource.Loading(data)
|
| 287 |
}
|
| 288 |
}
|
| 289 |
+
data.result?.let {
|
| 290 |
+
resource.value = ApiResource.Loading(data)
|
| 291 |
+
}
|
| 292 |
}
|
| 293 |
} catch (exception: Exception) {
|
| 294 |
resource.value = ApiResource.Error(exception.toString())
|