2616: Save Scheduled Time for Drafts. (#2624)
* 2616: Save Scheduled Time for Drafts. Signed-off-by: Martin Marconcini <martin.marconcini.rodriguez@nl.abnamro.com> * Revert 39.json schema to the original state before my changes.
This commit is contained in:
parent
1b6a0908f6
commit
8b026991e0
8 changed files with 965 additions and 10 deletions
|
@ -76,6 +76,7 @@ class ComposeViewModel @Inject constructor(
|
|||
|
||||
private var contentWarningStateChanged: Boolean = false
|
||||
private var modifiedInitialState: Boolean = false
|
||||
private var hasScheduledTimeChanged: Boolean = false
|
||||
|
||||
val instanceInfo: SharedFlow<InstanceInfo> = instanceInfoRepo::getInstanceInfo.asFlow()
|
||||
.shareIn(viewModelScope, SharingStarted.Eagerly, replay = 1)
|
||||
|
@ -214,8 +215,9 @@ class ComposeViewModel @Inject constructor(
|
|||
!startingContentWarning.startsWith(contentWarning.toString())
|
||||
val mediaChanged = media.value.isNotEmpty()
|
||||
val pollChanged = poll.value != null
|
||||
val didScheduledTimeChange = hasScheduledTimeChanged
|
||||
|
||||
return modifiedInitialState || textChanged || contentWarningChanged || mediaChanged || pollChanged
|
||||
return modifiedInitialState || textChanged || contentWarningChanged || mediaChanged || pollChanged || didScheduledTimeChange
|
||||
}
|
||||
|
||||
fun contentWarningChanged(value: Boolean) {
|
||||
|
@ -257,7 +259,8 @@ class ComposeViewModel @Inject constructor(
|
|||
mediaUris = mediaUris,
|
||||
mediaDescriptions = mediaDescriptions,
|
||||
poll = poll.value,
|
||||
failedToSend = false
|
||||
failedToSend = false,
|
||||
scheduledAt = scheduledAt.value
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -456,6 +459,10 @@ class ComposeViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
fun updateScheduledAt(newScheduledAt: String?) {
|
||||
if (newScheduledAt != scheduledAt.value) {
|
||||
hasScheduledTimeChanged = true
|
||||
}
|
||||
|
||||
scheduledAt.value = newScheduledAt
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,8 @@ class DraftHelper @Inject constructor(
|
|||
mediaUris: List<String>,
|
||||
mediaDescriptions: List<String?>,
|
||||
poll: NewPoll?,
|
||||
failedToSend: Boolean
|
||||
failedToSend: Boolean,
|
||||
scheduledAt: String?
|
||||
) = withContext(Dispatchers.IO) {
|
||||
val externalFilesDir = context.getExternalFilesDir("Tusky")
|
||||
|
||||
|
@ -116,7 +117,8 @@ class DraftHelper @Inject constructor(
|
|||
visibility = visibility,
|
||||
attachments = attachments,
|
||||
poll = poll,
|
||||
failedToSend = failedToSend
|
||||
failedToSend = failedToSend,
|
||||
scheduledAt = scheduledAt
|
||||
)
|
||||
|
||||
draftDao.insertOrReplace(draft)
|
||||
|
|
|
@ -106,7 +106,8 @@ class DraftsActivity : BaseActivity(), DraftActionListener {
|
|||
draftAttachments = draft.attachments,
|
||||
poll = draft.poll,
|
||||
sensitive = draft.sensitive,
|
||||
visibility = draft.visibility
|
||||
visibility = draft.visibility,
|
||||
scheduledAt = draft.scheduledAt
|
||||
)
|
||||
|
||||
bottomSheet.state = BottomSheetBehavior.STATE_HIDDEN
|
||||
|
@ -143,7 +144,8 @@ class DraftsActivity : BaseActivity(), DraftActionListener {
|
|||
draftAttachments = draft.attachments,
|
||||
poll = draft.poll,
|
||||
sensitive = draft.sensitive,
|
||||
visibility = draft.visibility
|
||||
visibility = draft.visibility,
|
||||
scheduledAt = draft.scheduledAt
|
||||
)
|
||||
|
||||
startActivity(ComposeActivity.startIntent(this, composeOptions))
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.io.File;
|
|||
*/
|
||||
@Database(entities = { DraftEntity.class, AccountEntity.class, InstanceEntity.class, TimelineStatusEntity.class,
|
||||
TimelineAccountEntity.class, ConversationEntity.class
|
||||
}, version = 40)
|
||||
}, version = 41)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
|
||||
public abstract AccountDao accountDao();
|
||||
|
@ -594,4 +594,11 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE `InstanceEntity` ADD COLUMN `maxFieldValueLength` INTEGER");
|
||||
}
|
||||
};
|
||||
|
||||
public static final Migration MIGRATION_40_41 = new Migration(40, 41) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE `DraftEntity` ADD COLUMN `scheduledAt` TEXT");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ data class DraftEntity(
|
|||
val visibility: Status.Visibility,
|
||||
val attachments: List<DraftAttachment>,
|
||||
val poll: NewPoll?,
|
||||
val failedToSend: Boolean
|
||||
val failedToSend: Boolean,
|
||||
val scheduledAt: String?,
|
||||
)
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,7 @@ class AppModule {
|
|||
AppDatabase.MIGRATION_29_30, AppDatabase.MIGRATION_30_31, AppDatabase.MIGRATION_31_32,
|
||||
AppDatabase.MIGRATION_32_33, AppDatabase.MIGRATION_33_34, AppDatabase.MIGRATION_34_35,
|
||||
AppDatabase.MIGRATION_35_36, AppDatabase.MIGRATION_36_37, AppDatabase.MIGRATION_37_38,
|
||||
AppDatabase.MIGRATION_38_39, AppDatabase.MIGRATION_39_40
|
||||
AppDatabase.MIGRATION_38_39, AppDatabase.MIGRATION_39_40, AppDatabase.MIGRATION_40_41,
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
|
|
@ -257,7 +257,8 @@ class SendStatusService : Service(), Injectable {
|
|||
mediaUris = status.mediaUris,
|
||||
mediaDescriptions = status.mediaDescriptions,
|
||||
poll = status.poll,
|
||||
failedToSend = true
|
||||
failedToSend = true,
|
||||
scheduledAt = status.scheduledAt
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue