code refactoring

This commit is contained in:
2023-01-13 11:43:56 +01:00
parent dcd80b7366
commit 7d2503fe77
3 changed files with 15 additions and 14 deletions

View File

@@ -15,7 +15,6 @@
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.4",
"@reduxjs/toolkit": "^1.8.1",
"radash": "^10.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.1",
@@ -32,8 +31,6 @@
"@types/uuid": "^8.3.4",
"@vitejs/plugin-react": "^1.3.2",
"buffer": "^6.0.3",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"typescript": "^4.6.4",
"vite": "^2.9.10"
}

View File

@@ -1,28 +1,28 @@
// @ts-nocheck
import i18n from "../../assets/i18n.yaml";
import i18n from "../../assets/i18n.yaml"
export default class I18nBuilder {
private language: string;
private textMap = i18n.languages;
private language: string
private textMap = i18n.languages
constructor(language: string) {
this.language = language;
this.language = language
}
getLanguage(): string {
return this.language;
return this.language
}
setLanguage(language: string): void {
this.language = language;
this.language = language
}
t(key: string): string {
const map = this.textMap[this.language]
if (map) {
const translation = map[key];
return translation ?? 'caption not defined';
const translation = map[key]
return translation ?? 'caption not defined'
}
return 'caption not defined';
return 'caption not defined'
}
}

View File

@@ -20,10 +20,13 @@ export class RPCClient {
}
private sendHTTP<T>(req: RPCRequest) {
return new Promise<RPCResponse<T>>((resolve, reject) => {
return new Promise<RPCResponse<T>>((resolve) => {
fetch(getHttpRPCEndpoint(), {
method: 'POST',
body: JSON.stringify(req)
body: JSON.stringify({
id: this.incrementSeq(),
...req
})
})
.then(res => res.json())
.then(data => resolve(data))
@@ -59,6 +62,7 @@ export class RPCClient {
public running() {
this.send({
id: this.incrementSeq(),
method: 'Service.Running',
params: [],
})