1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +00:00

preserve collection ids on save

This commit is contained in:
Kyle Spearrin
2017-11-23 22:33:08 -05:00
parent 634aa43694
commit b3d34e86fd
2 changed files with 10 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ class CipherData {
attachments?: AttachmentData[]; attachments?: AttachmentData[];
collectionIds?: string[]; collectionIds?: string[];
constructor(response: CipherResponse, userId: string) { constructor(response: CipherResponse, userId: string, collectionIds?: string[]) {
this.id = response.id; this.id = response.id;
this.organizationId = response.organizationId; this.organizationId = response.organizationId;
this.folderId = response.folderId; this.folderId = response.folderId;
@@ -40,7 +40,12 @@ class CipherData {
this.favorite = response.favorite; this.favorite = response.favorite;
this.revisionDate = response.revisionDate; this.revisionDate = response.revisionDate;
this.type = response.type; this.type = response.type;
if (collectionIds != null) {
this.collectionIds = collectionIds;
} else {
this.collectionIds = response.collectionIds; this.collectionIds = response.collectionIds;
}
this.name = response.data.Name; this.name = response.data.Name;
this.notes = response.data.Notes; this.notes = response.data.Notes;

View File

@@ -82,6 +82,7 @@ export default class CipherService {
cipher.favorite = model.favorite; cipher.favorite = model.favorite;
cipher.organizationId = model.organizationId; cipher.organizationId = model.organizationId;
cipher.type = model.type; cipher.type = model.type;
cipher.collectionIds = model.collectionIds;
const key = await this.cryptoService.getOrgKey(cipher.organizationId); const key = await this.cryptoService.getOrgKey(cipher.organizationId);
await Promise.all([ await Promise.all([
@@ -295,7 +296,7 @@ export default class CipherService {
} }
const userId = await this.userService.getUserId(); const userId = await this.userService.getUserId();
const data = new CipherData(response, userId); const data = new CipherData(response, userId, cipher.collectionIds);
await this.upsert(data); await this.upsert(data);
} }
@@ -324,7 +325,7 @@ export default class CipherService {
} }
const userId = await self.userService.getUserId(); const userId = await self.userService.getUserId();
const data = new CipherData(response, userId); const data = new CipherData(response, userId, cipher.collectionIds);
this.upsert(data); this.upsert(data);
resolve(new Cipher(data)); resolve(new Cipher(data));