mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PS 1504]Windows CLI - JSON Exports Missing Folders (#4113)
* Replace the FolderView from Observable with getAllDecryptedFromState * Fixing failed test * Fixing the PR comment on addressing getEncryptedExport * Fixing the failing test cases * Adding some unit test to check folder is exported * Fixing a failing test * Rename to getAllFromState to conform * Please rename to getAllFromState to conform test Co-authored-by: dynwee <onwudiweokeke@gmail.com>
This commit is contained in:
@@ -12,6 +12,7 @@ export abstract class FolderService {
|
||||
clearCache: () => Promise<void>;
|
||||
encrypt: (model: FolderView, key?: SymmetricCryptoKey) => Promise<Folder>;
|
||||
get: (id: string) => Promise<Folder>;
|
||||
getAllFromState: () => Promise<Folder[]>;
|
||||
/**
|
||||
* @deprecated Only use in CLI!
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as papa from "papaparse";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CipherService } from "../abstractions/cipher.service";
|
||||
@@ -116,7 +115,7 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
const promises = [];
|
||||
|
||||
promises.push(
|
||||
firstValueFrom(this.folderService.folderViews$).then((folders) => {
|
||||
this.folderService.getAllDecryptedFromState().then((folders) => {
|
||||
decFolders = folders;
|
||||
})
|
||||
);
|
||||
@@ -192,7 +191,7 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
const promises = [];
|
||||
|
||||
promises.push(
|
||||
firstValueFrom(this.folderService.folders$).then((f) => {
|
||||
this.folderService.getAllFromState().then((f) => {
|
||||
folders = f;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -64,6 +64,18 @@ export class FolderService implements InternalFolderServiceAbstraction {
|
||||
return folders.find((folder) => folder.id === id);
|
||||
}
|
||||
|
||||
async getAllFromState(): Promise<Folder[]> {
|
||||
const folders = await this.stateService.getEncryptedFolders();
|
||||
const response: Folder[] = [];
|
||||
for (const id in folders) {
|
||||
// eslint-disable-next-line
|
||||
if (folders.hasOwnProperty(id)) {
|
||||
response.push(new Folder(folders[id]));
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated For the CLI only
|
||||
* @param id id of the folder
|
||||
|
||||
Reference in New Issue
Block a user