Save draft when redrafting a post (#1744)

This commit is contained in:
Levi Bard 2020-10-02 18:32:46 +02:00 committed by Alibek Omarov
parent f47265d920
commit b32a7523d1
4 changed files with 9 additions and 5 deletions

View File

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

View File

@ -1317,7 +1317,8 @@ class ComposeActivity : BaseActivity(),
var scheduledAt: String? = null,
var sensitive: Boolean? = null,
var poll: NewPoll? = null,
var formattingSyntax: String? = null
var formattingSyntax: String? = 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
public var formattingSyntax: String = ""
private var modifiedInitialState: Boolean = false
val markMediaAsSensitive =
mutableLiveData(accountManager.activeAccount?.defaultMediaSensitivity ?: false)
@ -88,7 +89,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) {
@ -186,7 +187,7 @@ class ComposeViewModel
preferredVisibility.num.coerceAtLeast(replyVisibility.num))
inReplyToId = composeOptions?.inReplyToId
modifiedInitialState = composeOptions?.modifiedInitialState == true
val contentWarning = composeOptions?.contentWarning
if (contentWarning != null) {
@ -266,4 +267,4 @@ class ComposeViewModel
private companion object {
const val TAG = "ComposeViewModel"
}
}
}

View File

@ -487,6 +487,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()));
}