1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

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) { if (obj.attachments != null) {
this.attachments = []; this.attachments = [];
for (const attachment of obj.attachments) { obj.attachments.forEach((attachment) => {
this.attachments.push(new Attachment(attachment, alreadyEncrypted)); this.attachments.push(new Attachment(attachment, alreadyEncrypted));
} });
} else { } else {
this.attachments = null; this.attachments = null;
} }
if (obj.fields != null) { if (obj.fields != null) {
this.fields = []; this.fields = [];
for (const field of obj.fields) { obj.fields.forEach((field) => {
this.fields.push(new Field(field, alreadyEncrypted)); this.fields.push(new Field(field, alreadyEncrypted));
} });
} else { } else {
this.fields = null; this.fields = null;
} }

View File

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

View File

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

View File

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