edge hates `for of` loops

This commit is contained in:
Kyle Spearrin 2017-11-15 16:07:38 -05:00
parent 85447bb2ab
commit 5fa5fbc496
5 changed files with 36 additions and 39 deletions

View File

@ -71,18 +71,18 @@ class Cipher extends Domain {
if (obj.attachments != null) {
this.attachments = [];
for (const attachment of obj.attachments) {
obj.attachments.forEach((attachment) => {
this.attachments.push(new Attachment(attachment, alreadyEncrypted));
}
});
} else {
this.attachments = null;
}
if (obj.fields != null) {
this.fields = [];
for (const field of obj.fields) {
obj.fields.forEach((field) => {
this.fields.push(new Field(field, alreadyEncrypted));
}
});
} else {
this.fields = null;
}

View File

@ -74,13 +74,13 @@ class CipherRequest {
if (cipher.fields) {
this.fields = [];
for (const field of cipher.fields) {
cipher.fields.forEach((field: any) => {
this.fields.push({
type: field.type,
name: field.name ? field.name.encryptedString : null,
value: field.value ? field.value.encryptedString : null,
});
}
});
}
}
}

View File

@ -25,9 +25,9 @@ class CipherResponse {
if (response.Attachments != null) {
this.attachments = [];
for (const attachment of response.Attachments) {
response.Attachments.forEach((attachment: any) => {
this.attachments.push(new AttachmentResponse(attachment));
}
});
}
}
}

View File

@ -1,3 +1,5 @@
import { CipherType } from '../../../enums/cipherType.enum';
import { UtilsService } from '../../../services/abstractions/utils.service';
import * as template from './current.component.html';
@ -15,10 +17,8 @@ class CurrentController {
disableSearch: boolean = false;
constructor($scope: any, private cipherService: any, private utilsService: UtilsService, private toastr: any,
private $window: any, private $state: any, private $timeout: any, private autofillService: any,
private $analytics: any, private i18nService: any, private constantsService: any,
private $filter: any) {
private $window: any, private $state: any, private $timeout: any, private autofillService: any,
private $analytics: any, private i18nService: any, private $filter: any) {
this.i18n = i18nService;
this.inSidebar = utilsService.inSidebar($window);
this.disableSearch = utilsService.isEdge();
@ -67,25 +67,22 @@ class CurrentController {
this.toastr.error(this.i18nService.autofillError);
}
this.autofillService
.doAutoFill({
cipher,
pageDetails: this.pageDetails,
fromBackground: false,
})
.then((totpCode: string) => {
this.$analytics.eventTrack('Autofilled');
if (totpCode && this.utilsService.isFirefox()) {
this.utilsService.copyToClipboard(totpCode, document);
}
if (this.utilsService.inPopup(this.$window)) {
this.$window.close();
}
})
.catch(() => {
this.$analytics.eventTrack('Autofilled Error');
this.toastr.error(this.i18nService.autofillError);
});
this.autofillService.doAutoFill({
cipher,
pageDetails: this.pageDetails,
fromBackground: false,
}).then((totpCode: string) => {
this.$analytics.eventTrack('Autofilled');
if (totpCode && this.utilsService.isFirefox()) {
this.utilsService.copyToClipboard(totpCode, document);
}
if (this.utilsService.inPopup(this.$window)) {
this.$window.close();
}
}).catch(() => {
this.$analytics.eventTrack('Autofilled Error');
this.toastr.error(this.i18nService.autofillError);
});
}
searchVault() {
@ -116,21 +113,21 @@ class CurrentController {
});
const otherTypes = [
this.constantsService.cipherType.card,
this.constantsService.cipherType.identity,
CipherType.Card,
CipherType.Identity,
];
this.cipherService.getAllDecryptedForDomain(this.domain, otherTypes).then((ciphers: any) => {
this.cipherService.getAllDecryptedForDomain(this.domain, otherTypes).then((ciphers: any[]) => {
const loginCiphers: any = [];
const otherCiphers: any = [];
for (const cipher of ciphers) {
if (cipher.type === this.constantsService.cipherType.login) {
ciphers.forEach((cipher) => {
if (cipher.type === CipherType.Login) {
loginCiphers.push(cipher);
} else {
otherCiphers.push(cipher);
}
}
});
this.$timeout(() => {
this.loginCiphers = this.$filter('orderBy')(

View File

@ -13,11 +13,11 @@ class ValidationService {
} else if (!data.validationErrors) {
errors.push(data.message ? data.message : defaultErrorMessage);
} else {
for (const error of data.validationErrors) {
data.validationErrors.forEach((error: any) => {
error.forEach((item: string) => {
errors.push(item);
});
}
});
}
if (errors.length) {