Skip to content

Commit d80cac1

Browse files
committed
fix: Enable polling, better debouncing
1 parent af32420 commit d80cac1

File tree

8 files changed

+610
-36
lines changed

8 files changed

+610
-36
lines changed

package-lock.json

Lines changed: 118 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"author": "Jan Cizmar",
3131
"license": "MIT",
3232
"dependencies": {
33+
"@stomp/stompjs": "^7.1.1",
3334
"ajv": "^8.17.1",
3435
"ansi-colors": "^4.1.3",
3536
"base32-decode": "^1.0.0",
@@ -38,10 +39,12 @@
3839
"json5": "^2.2.3",
3940
"jsonschema": "^1.5.0",
4041
"openapi-fetch": "0.13.1",
42+
"sockjs-client": "^1.6.1",
4143
"tinyglobby": "^0.2.12",
4244
"unescape-js": "^1.1.4",
4345
"vscode-oniguruma": "^2.0.1",
4446
"vscode-textmate": "^9.1.0",
47+
"ws": "^8.18.3",
4548
"yauzl": "^3.2.0"
4649
},
4750
"devDependencies": {

src/client/ExportClient.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { ApiClient } from './ApiClient.js';
55
export type ExportRequest = Omit<
66
BodyOf<'/v2/projects/{projectId}/export', 'post'>,
77
'zip'
8-
>;
8+
> & {
9+
ifModifiedSince?: string;
10+
};
911

1012
type SingleExportRequest = Omit<ExportRequest, 'languages'> & {
1113
languages: [string];
@@ -18,10 +20,16 @@ type ExportClientProps = {
1820
export const createExportClient = ({ apiClient }: ExportClientProps) => {
1921
return {
2022
async export(req: ExportRequest) {
21-
const body = { ...req, zip: true };
23+
const { ifModifiedSince, ...exportReq } = req;
24+
const body = { ...exportReq, zip: true };
25+
const headers: Record<string, string> = {};
26+
if (ifModifiedSince) {
27+
headers['If-Modified-Since'] = ifModifiedSince;
28+
}
2229
const loadable = await apiClient.POST('/v2/projects/{projectId}/export', {
2330
params: { path: { projectId: apiClient.getProjectId() } },
2431
body: body,
32+
headers,
2533
parseAs: 'blob',
2634
});
2735
return { ...loadable, data: loadable.data as unknown as Blob };

src/client/TolgeeClient.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ export function createTolgeeClient(props: Props) {
2222

2323
export const handleLoadableError = (loadable: LoadableData) => {
2424
if (loadable.error) {
25-
exitWithError(errorFromLoadable(loadable));
25+
throw new LoadableError(loadable);
2626
}
2727
};
2828

29+
export class LoadableError extends Error {
30+
constructor(public loadable: LoadableData) {
31+
super(errorFromLoadable(loadable));
32+
}
33+
}
34+
2935
export type TolgeeClient = ReturnType<typeof createTolgeeClient>;

0 commit comments

Comments
 (0)