Save draft when redrafting a post (#1744)

This commit is contained in:
Levi Bard 2020-10-02 18:32:46 +02:00 committed by GitHub
parent 26a051220b
commit e237639adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View File

@ -178,7 +178,8 @@ public final class SavedTootActivity extends BaseActivity implements SavedTootAd
/*mediaAttachments*/null,
/*scheduledAt*/null,
/*sensitive*/null,
/*poll*/null
/*poll*/null,
/* modifiedInitialState */ true
);
Intent intent = ComposeActivity.startIntent(this, composeOptions);
startActivity(intent);

View File

@ -1008,7 +1008,8 @@ class ComposeActivity : BaseActivity(),
var mediaAttachments: List<Attachment>? = null,
var scheduledAt: String? = null,
var sensitive: Boolean? = null,
var poll: NewPoll? = null
var poll: NewPoll? = null,
var modifiedInitialState: Boolean? = null
) : Parcelable
companion object {

View File

@ -63,6 +63,7 @@ class ComposeViewModel
private var startingVisibility: Status.Visibility = Status.Visibility.UNKNOWN
private var contentWarningStateChanged: Boolean = false
private var modifiedInitialState: Boolean = false
private val instance: MutableLiveData<InstanceEntity?> = MutableLiveData(null)
@ -197,7 +198,7 @@ class ComposeViewModel
val mediaChanged = !media.value.isNullOrEmpty()
val pollChanged = poll.value != null
return textChanged || contentWarningChanged || mediaChanged || pollChanged
return modifiedInitialState || textChanged || contentWarningChanged || mediaChanged || pollChanged
}
fun contentWarningChanged(value: Boolean) {
@ -369,7 +370,7 @@ class ComposeViewModel
preferredVisibility.num.coerceAtLeast(replyVisibility.num))
inReplyToId = composeOptions?.inReplyToId
modifiedInitialState = composeOptions?.modifiedInitialState == true
val contentWarning = composeOptions?.contentWarning
if (contentWarning != null) {

View File

@ -457,6 +457,7 @@ public abstract class SFragment extends BaseFragment implements Injectable {
composeOptions.setContentWarning(deletedStatus.getSpoilerText());
composeOptions.setMediaAttachments(deletedStatus.getAttachments());
composeOptions.setSensitive(deletedStatus.getSensitive());
composeOptions.setModifiedInitialState(true);
if (deletedStatus.getPoll() != null) {
composeOptions.setPoll(deletedStatus.getPoll().toNewPoll(deletedStatus.getCreatedAt()));
}