Skip to content

Commit b35c20e

Browse files
committed
Add type for UserAction
1 parent 114a76b commit b35c20e

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

src/api/atelier.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ interface ServerInfoFeature {
2424
enabled: string;
2525
}
2626

27+
export interface UserAction {
28+
action: number;
29+
target: string;
30+
message: string;
31+
reload: boolean;
32+
doc: any;
33+
errorText: string;
34+
}
35+
2736
export interface Document {
2837
name: string;
2938
db: string;
@@ -34,7 +43,7 @@ export interface Document {
3443
enc: boolean;
3544
flags: number;
3645
content: string[] | Buffer;
37-
ext: string;
46+
ext?: UserAction | UserAction[];
3847
}
3948

4049
export interface ServerInfo {

src/commands/delete.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { explorerProvider } from "../extension";
88
import { outputChannel } from "../utils";
99
import { OtherStudioAction, fireOtherStudioAction } from "./studio";
1010
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
11+
import { UserAction } from "../api/atelier";
1112

1213
function deleteList(items: string[], workspaceFolder: string, namespace: string): Promise<any> {
1314
if (!items || !items.length) {
@@ -20,7 +21,7 @@ function deleteList(items: string[], workspaceFolder: string, namespace: string)
2021
files.forEach((file) => {
2122
if (file.result.ext) {
2223
const uri = DocumentContentProvider.getUri(file.result.name);
23-
fireOtherStudioAction(OtherStudioAction.DeletedDocument, uri, file.result.ext);
24+
fireOtherStudioAction(OtherStudioAction.DeletedDocument, uri, <UserAction>file.result.ext);
2425
}
2526
});
2627
outputChannel.appendLine(`Deleted items: ${files.filter((el) => el.result).length}`);

src/commands/studio.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { RoutineNode } from "../explorer/models/routineNode";
99
import { importAndCompile } from "./compile";
1010
import { ProjectNode } from "../explorer/models/projectNode";
1111
import { openCustomEditors } from "../providers/RuleEditorProvider";
12+
import { UserAction } from "../api/atelier";
1213

1314
export let documentBeingProcessed: vscode.TextDocument = null;
1415

@@ -119,9 +120,8 @@ export class StudioActions {
119120
);
120121
}
121122

122-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
123-
public processUserAction(userAction): Thenable<any> {
124-
const serverAction = parseInt(userAction.action || 0, 10);
123+
public processUserAction(userAction: UserAction): Thenable<any> {
124+
const serverAction = userAction.action;
125125
const { target, errorText } = userAction;
126126
if (errorText !== "") {
127127
outputChannel.appendLine(errorText);
@@ -314,7 +314,7 @@ export class StudioActions {
314314
this.projectEditAnswer = "1";
315315
return;
316316
}
317-
const actionToProcess = data.result.content.pop();
317+
const actionToProcess: UserAction = data.result.content.pop();
318318

319319
if (actionToProcess.reload) {
320320
// Avoid the reload triggering the edit listener here
@@ -429,8 +429,7 @@ export class StudioActions {
429429
.then((action) => this.userAction(action));
430430
}
431431

432-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
433-
public fireOtherStudioAction(action: OtherStudioAction, userAction?): void {
432+
public fireOtherStudioAction(action: OtherStudioAction, userAction?: UserAction): void {
434433
const actionObject = {
435434
id: action.toString(),
436435
label: getOtherStudioActionLabel(action),
@@ -560,8 +559,11 @@ export async function _contextMenu(sourceControl: boolean, node: PackageNode | C
560559
}
561560
}
562561

563-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
564-
export async function fireOtherStudioAction(action: OtherStudioAction, uri?: vscode.Uri, userAction?): Promise<void> {
562+
export async function fireOtherStudioAction(
563+
action: OtherStudioAction,
564+
uri?: vscode.Uri,
565+
userAction?: UserAction
566+
): Promise<void> {
565567
if (vscode.workspace.getConfiguration("objectscript.serverSourceControl", uri)?.get("disableOtherActionTriggers")) {
566568
return;
567569
}

src/providers/FileSystemProvider/FileSystemProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { config, intLangId, macLangId, workspaceState } from "../../extension";
1717
import { addIsfsFileToProject, modifyProject } from "../../commands/project";
1818
import { DocumentContentProvider } from "../DocumentContentProvider";
19-
import { Document } from "../../api/atelier";
19+
import { Document, UserAction } from "../../api/atelier";
2020

2121
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
2222

@@ -453,7 +453,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
453453
const events: vscode.FileChangeEvent[] = [];
454454
try {
455455
if (doc.ext) {
456-
fireOtherStudioAction(OtherStudioAction.DeletedDocument, uri, doc.ext);
456+
fireOtherStudioAction(OtherStudioAction.DeletedDocument, uri, <UserAction>doc.ext);
457457
}
458458
// Remove entry from our cache, plus any now-empty ancestor entries
459459
let thisUri = vscode.Uri.parse(uri.toString(), true);

0 commit comments

Comments
 (0)