-
Notifications
You must be signed in to change notification settings - Fork 34
/
fileDataMap.ts
72 lines (62 loc) · 2.23 KB
/
fileDataMap.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import * as vscode from "vscode";
import { FileData } from "./fileData";
import { IAttributePath } from "../common/interfaces";
export class FileDataMap {
private fileMap: Map<string, FileData> = new Map<string, FileData>();
public get getFileMap(): Map<string, FileData> {
return this.fileMap;
}
public setEntity(
fileUri: string,
entityId: string,
entityName: string,
fileName: string,
odataEtag: string,
fileExtension: string,
attributePath: IAttributePath,
isBase64Encoded: boolean,
mimeType?: string,
isContentLoaded?: boolean
) {
const fileData = new FileData(
entityId,
entityName,
fileName,
odataEtag,
fileExtension,
attributePath,
isBase64Encoded,
mimeType,
isContentLoaded
);
this.fileMap.set(vscode.Uri.parse(fileUri).fsPath, fileData);
}
public updateDirtyChanges(fileFsPath: string, dirtyFlagValue: boolean) {
const existingEntity = this.fileMap.get(fileFsPath);
if (existingEntity) {
existingEntity.setHasDirtyChanges = dirtyFlagValue;
return;
}
throw Error("File does not exist in the map"); // TODO - Revisit errors and dialog experience here
}
public updateDiffViewTriggered(fileFsPath: string, diffViewTriggerValue: boolean) {
const existingEntity = this.fileMap.get(fileFsPath);
if (existingEntity) {
existingEntity.setHasDiffViewTriggered = diffViewTriggerValue;
return;
}
throw Error("File does not exist in the map"); // TODO - Revisit errors and dialog experience here
}
public updateEtagValue(fileFsPath: string, etag: string) {
const existingEntity = this.fileMap.get(fileFsPath);
if (existingEntity) {
existingEntity.setEntityEtag = etag;
return;
}
throw Error("File does not exist in the map"); // TODO - Revisit errors and dialog experience here
}
}