Skip to content

Commit 69c2cf4

Browse files
author
Arief Nur Putranto
committed
fix issue status bubble message failed and pending changed to read after receiving new message
1 parent 2fa8d32 commit 69c2cf4

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

QiscusCore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "QiscusCore"
3-
s.version = "1.13.2"
3+
s.version = "1.13.3"
44
s.summary = "Qiscus Core SDK for iOS"
55
s.description = <<-DESC
66
Qiscus SDK for iOS contains Qiscus public Model.

Source/QiscusCore/Database/QiscusDatabaseManager.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,13 @@ public class CommentDB {
267267
let myCommentBefore = myComments.filter({ $0.unixTimestamp < comment.unixTimestamp })
268268
for c in myCommentBefore {
269269
// update comment
270-
if c.status.intValue < comment.status.intValue {
271-
c.status = .read
272-
QiscusCore.database.comment.save([c])
270+
if c.status.intValue < comment.status.intValue{
271+
if c.status == .pending || c.status == .failed {
272+
//no action
273+
}else{
274+
c.status = .read
275+
QiscusCore.database.comment.save([c])
276+
}
273277
}
274278
}
275279
}

Source/QiscusCore/QiscusComment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension QiscusCore {
116116

117117
if error != nil {
118118
//check error
119-
if (error?.contains("Validation error") == true){
119+
if (error?.contains("Validation error") == true || error?.contains("Response not JSON or undefined") == true){
120120
//save in local comment failed
121121
_comment.status = .failed
122122
QiscusCore.database.comment.save([_comment])
@@ -208,7 +208,7 @@ extension QiscusCore {
208208

209209
if error != nil {
210210
//check error
211-
if (error?.contains("Validation error") == true){
211+
if (error?.contains("Validation error") == true || error?.contains("Response not JSON or undefined") == true){
212212
//save in local comment failed
213213
_comment.status = .failed
214214
QiscusCore.database.comment.save([_comment])

Source/QiscusCore/QiscusWorkerManager.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ class QiscusWorkerManager {
203203

204204
private func sendPendingMessage(){
205205
guard let comments = QiscusCore.database.comment.find(status: .pending) else { return }
206+
207+
if comments.count >= 1 {
208+
self.synchronize()
209+
}
210+
211+
206212
comments.reversed().forEach { (c) in
207213
// validation comment prevent id
208214
if c.uniqId.isEmpty { QiscusCore.database.comment.evaluate(); return }

0 commit comments

Comments
 (0)