1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

Date time fallback fixes (#292)

* tightened up the Send datetime fallback conditionals

* cleaned up
This commit is contained in:
Addison Beck 2021-03-02 17:00:07 -05:00 committed by GitHub
parent 36089fd68f
commit f836629b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,7 @@ export class AddEditComponent implements OnInit {
deletionDate: string; deletionDate: string;
deletionDateFallback: string; deletionDateFallback: string;
deletionTimeFallback: string; deletionTimeFallback: string;
expirationDate: string; expirationDate: string = null;
expirationDateFallback: string; expirationDateFallback: string;
expirationTimeFallback: string; expirationTimeFallback: string;
hasPassword: boolean; hasPassword: boolean;
@ -156,11 +156,16 @@ export class AddEditComponent implements OnInit {
// Parse dates // Parse dates
if (!this.isDateTimeLocalSupported) { if (!this.isDateTimeLocalSupported) {
const deletionDateParts = this.dateToSplitString(this.send.deletionDate); const deletionDateParts = this.dateToSplitString(this.send.deletionDate);
this.deletionDateFallback = deletionDateParts[0]; if (deletionDateParts !== undefined && deletionDateParts.length > 0) {
this.deletionTimeFallback = deletionDateParts[1]; this.deletionDateFallback = deletionDateParts[0];
this.deletionTimeFallback = deletionDateParts[1];
}
const expirationDateParts = this.dateToSplitString(this.send.expirationDate); const expirationDateParts = this.dateToSplitString(this.send.expirationDate);
this.expirationDateFallback = expirationDateParts[0]; if (expirationDateParts !== undefined && expirationDateParts.length > 0) {
this.expirationTimeFallback = expirationDateParts[1]; this.expirationDateFallback = expirationDateParts[0];
this.expirationTimeFallback = expirationDateParts[1];
}
} else { } else {
this.deletionDate = this.dateToString(this.send.deletionDate); this.deletionDate = this.dateToString(this.send.deletionDate);
this.expirationDate = this.dateToString(this.send.expirationDate); this.expirationDate = this.dateToString(this.send.expirationDate);
@ -168,12 +173,11 @@ export class AddEditComponent implements OnInit {
} }
async submit(): Promise<boolean> { async submit(): Promise<boolean> {
if (!this.isDateTimeLocalSupported && this.expirationDateTimeFallback !== null) { if (!this.isDateTimeLocalSupported) {
this.expirationDate = this.expirationDateTimeFallback;
}
if (!this.isDateTimeLocalSupported && this.deletionDateTimeFallback !== null) {
this.deletionDate = this.deletionDateTimeFallback; this.deletionDate = this.deletionDateTimeFallback;
if ((this.editMode && this.expirationDateFallback != null) || this.expirationDateSelect === 0) {
this.expirationDate = this.expirationDateTimeFallback;
}
} }
if (this.disableSend) { if (this.disableSend) {