Fix thread update with drafts bugs.
* Fix thread not updating correctly when drafts are present. * Fix thread delete bug during first message drafting.
This commit is contained in:
parent
9ee10512fb
commit
dfb913cb98
3 changed files with 13 additions and 2 deletions
|
@ -48,8 +48,8 @@ class DraftRepository(
|
||||||
draftDatabase.replaceDrafts(actualThreadId, drafts)
|
draftDatabase.replaceDrafts(actualThreadId, drafts)
|
||||||
threadDatabase.updateSnippet(actualThreadId, drafts.getSnippet(context), drafts.uriSnippet, System.currentTimeMillis(), MmsSmsColumns.Types.BASE_DRAFT_TYPE, true)
|
threadDatabase.updateSnippet(actualThreadId, drafts.getSnippet(context), drafts.uriSnippet, System.currentTimeMillis(), MmsSmsColumns.Types.BASE_DRAFT_TYPE, true)
|
||||||
} else if (threadId > 0) {
|
} else if (threadId > 0) {
|
||||||
threadDatabase.update(threadId, false)
|
|
||||||
draftDatabase.clearDrafts(threadId)
|
draftDatabase.clearDrafts(threadId)
|
||||||
|
threadDatabase.update(threadId, unarchive = false, allowDeletion = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class DraftViewModel @JvmOverloads constructor(
|
||||||
return repository
|
return repository
|
||||||
.loadDrafts(threadId)
|
.loadDrafts(threadId)
|
||||||
.doOnSuccess { drafts ->
|
.doOnSuccess { drafts ->
|
||||||
store.update { it.copyAndSetDrafts(threadId, drafts.drafts) }
|
store.update { saveDrafts(it.copyAndSetDrafts(threadId, drafts.drafts)) }
|
||||||
}
|
}
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1327,6 +1327,17 @@ class ThreadDatabase(context: Context, databaseHelper: SignalDatabase) : Databas
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val drafts: DraftDatabase.Drafts = SignalDatabase.drafts.getDrafts(threadId)
|
||||||
|
if (drafts.isNotEmpty()) {
|
||||||
|
val threadRecord: ThreadRecord? = getThreadRecord(threadId)
|
||||||
|
if (threadRecord != null &&
|
||||||
|
threadRecord.type == MmsSmsColumns.Types.BASE_DRAFT_TYPE &&
|
||||||
|
threadRecord.date > record.timestamp
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateThread(
|
updateThread(
|
||||||
threadId = threadId,
|
threadId = threadId,
|
||||||
meaningfulMessages = meaningfulMessages,
|
meaningfulMessages = meaningfulMessages,
|
||||||
|
|
Loading…
Add table
Reference in a new issue