Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Dec 23, 2023
1 parent 1e8c835 commit a184162
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/client/crowdinClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class CrowdinClient {
readonly apiKey: string,
readonly docUri: vscode.Uri,
readonly branch?: string,
readonly organization?: string
readonly organization?: string,
readonly stringsBased?: boolean
) {
const credentials: Credentials = {
token: apiKey,
Expand Down Expand Up @@ -185,6 +186,8 @@ export class CrowdinClient {
scheme?: Scheme,
type?: SourceFilesModel.FileType
): Promise<void> {
//TODO handle strings based projects

let branchId: number | undefined;
const branch = this.crowdinBranch;

Expand Down
4 changes: 2 additions & 2 deletions src/config/configModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export interface ConfigModel {
files: FileModel[];
}

export function buildClient(docUri: vscode.Uri, config: ConfigModel) {
return new CrowdinClient(config.projectId, config.apiKey, docUri, config.branch, config.organization);
export function buildClient(docUri: vscode.Uri, config: ConfigModel, stringsBased = false) {
return new CrowdinClient(config.projectId, config.apiKey, docUri, config.branch, config.organization, stringsBased);
}
4 changes: 3 additions & 1 deletion src/plugin/progress/progressTreeProvider.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ProjectsGroupsModel } from '@crowdin/crowdin-api-client';
import * as path from 'path';
import * as vscode from 'vscode';
import { buildClient } from '../../config/configModel';
Expand Down Expand Up @@ -27,7 +28,8 @@ export class ProgressTreeProvider implements vscode.TreeDataProvider<ProgressTre
const configurations = await this.configHolder.configurations();
const promises = Array.from(configurations).map(async ([{ config, project }, workspace]) => {
try {
const client = buildClient(workspace.uri, config);
const isStringsBased = project.type === ProjectsGroupsModel.Type.STRINGS_BASED;
const client = buildClient(workspace.uri, config, isStringsBased);
const { translationStatusApi, languagesApi } = client.crowdin;
const languages = await languagesApi.withFetchAll().listSupportedLanguages();
const progress = await translationStatusApi.withFetchAll().getProjectProgress(config.projectId);
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/tree/bundles/bundlesTreeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BundlesTreeItem } from './bundlesTreeItem';

export class BundlesTreeBuilder {
static async buildBundlesTree(workspace: vscode.WorkspaceFolder, config: ConfigModel): Promise<BundlesTreeItem> {
const client = buildClient(workspace.uri, config);
const client = buildClient(workspace.uri, config, true);
return new BundlesTreeItem({
client,
label: workspace.name,
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/tree/treeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class TreeProvider implements vscode.TreeDataProvider<TreeItem> {
return rootTreeFolder;
}

const client = buildClient(workspace.uri, config);
const client = buildClient(workspace.uri, config, isStringsBased);

const rootTreeFolder = await FilesTreeBuilder.buildRootFolder(
workspace,
Expand Down

0 comments on commit a184162

Please sign in to comment.