コード整理
This commit is contained in:
parent
5f403695f1
commit
f4d014e404
|
@ -49,6 +49,7 @@ import kotlin.math.min
|
|||
private val log = LogCategory("ActPostAttachment")
|
||||
|
||||
// AppStateに保存する
|
||||
// シャローコピーなので attachmentList を変更する前後のどっちかで呼ばれてれば良い
|
||||
fun ActPost.saveAttachmentList() {
|
||||
if (!isMultiWindowPost) appState.attachmentList = this.attachmentList
|
||||
}
|
||||
|
|
|
@ -346,7 +346,6 @@ fun ActPost.initializeFromRedraftStatus(account: SavedAccount, jsonText: String)
|
|||
|
||||
val srcAttachments = baseStatus.media_attachments
|
||||
if (srcAttachments?.isNotEmpty() == true) {
|
||||
saveAttachmentList()
|
||||
this.attachmentList.clear()
|
||||
try {
|
||||
for (src in srcAttachments) {
|
||||
|
@ -360,6 +359,7 @@ fun ActPost.initializeFromRedraftStatus(account: SavedAccount, jsonText: String)
|
|||
} catch (ex: Throwable) {
|
||||
log.e(ex, "can't initialize attachments from redraft.")
|
||||
}
|
||||
saveAttachmentList()
|
||||
}
|
||||
|
||||
views.cbNSFW.isChecked = baseStatus.sensitive == true
|
||||
|
@ -443,7 +443,6 @@ fun ActPost.initializeFromEditStatus(account: SavedAccount, jsonText: String) {
|
|||
?.mapNotNull { it as? TootAttachment }
|
||||
?.notEmpty()
|
||||
?.let { srcAttachments ->
|
||||
saveAttachmentList()
|
||||
this.attachmentList.clear()
|
||||
for (src in srcAttachments) {
|
||||
try {
|
||||
|
@ -455,6 +454,7 @@ fun ActPost.initializeFromEditStatus(account: SavedAccount, jsonText: String) {
|
|||
log.e(ex, "can't initialize attachments from edit status")
|
||||
}
|
||||
}
|
||||
saveAttachmentList()
|
||||
}
|
||||
|
||||
views.cbNSFW.isChecked = baseStatus.sensitive == true
|
||||
|
|
|
@ -274,6 +274,7 @@ fun ActPost.performMore() {
|
|||
views.etContent.setText("")
|
||||
views.etContentWarning.setText("")
|
||||
attachmentList.clear()
|
||||
saveAttachmentList()
|
||||
showMediaAttachment()
|
||||
}
|
||||
|
||||
|
|
|
@ -65,9 +65,9 @@ suspend fun ActPost.initializeFromScheduledStatus(account: SavedAccount, jsonTex
|
|||
}
|
||||
?.notEmpty()
|
||||
?.let {
|
||||
saveAttachmentList()
|
||||
this.attachmentList.clear()
|
||||
this.attachmentList.addAll(it)
|
||||
saveAttachmentList()
|
||||
}
|
||||
} catch (ex: Throwable) {
|
||||
log.e(ex, "initializeFromScheduledStatus failed.")
|
||||
|
|
|
@ -98,8 +98,8 @@ suspend fun ActPost.restoreState(savedInstanceState: Bundle) {
|
|||
} else {
|
||||
// state から復元する
|
||||
states.attachmentListEncoded?.let {
|
||||
saveAttachmentList()
|
||||
decodeAttachments(it)
|
||||
saveAttachmentList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue