Skip to content

Commit

Permalink
Fix extension load problem
Browse files Browse the repository at this point in the history
  • Loading branch information
xjsender committed Aug 11, 2019
1 parent 9e2c74c commit f9ac7af
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
14 changes: 9 additions & 5 deletions src/salesforce/api/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export default class MetadataApi {
* @returns {Promise.<Response>}
*/
public describeMetadata() {
return this._invoke_method("DescribeMetadata");
return this._invoke_method({
"requestType": "DescribeMetadata"
});
}

/**
Expand All @@ -106,8 +108,9 @@ export default class MetadataApi {
*/
public checkRetriveStatus(options: any, progress?: any) {
let self = this;
let requestType = "CheckRetrieveStatus";
let soapBody = self.soap.getRequestBody(
"CheckRetrieveStatus", options
requestType, options
);

let requestOptions = {
Expand All @@ -122,11 +125,12 @@ export default class MetadataApi {

function recursiveCheck() {
request(requestOptions).then(body => {
let result = self.parseResult(body, "CheckRetrieveStatus");
let result = self.parseResult(body, requestType);

// Show progress status
ProgressNotification.notify(
progress, result["status"],
progress,
`[sf:retrieve] Request Status: ${result["status"]}`,
result["done"] ? 100 : undefined
);

Expand Down Expand Up @@ -159,7 +163,7 @@ export default class MetadataApi {

return new Promise<any>( (resolve, reject) => {
options["requestType"] = "Retrieve";
console.log(options);

ProgressNotification.showProgress(self, "_invoke_method", options)
.then( result => {
options["asyncProcessId"] = result["id"];
Expand Down
11 changes: 3 additions & 8 deletions src/salesforce/lib/auth/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as vscode from "vscode";
import * as moment from "moment";
import * as xmlParser from "fast-xml-parser";
import * as config from "./config";
import * as settingsUtil from "../../../settings/settingsUtil";
import { projectSession } from "../../../settings";
import { projectSession, metadata } from "../../../settings";
import * as util from "../../../utils/util";
import MetadataApi from "../../api/metadata";
import { OAuth } from "./oauth";
Expand Down Expand Up @@ -59,12 +58,8 @@ export function startServer(projectName: any, loginUrl: string) {
// Describe metadata
let metadataApi = new MetadataApi(session);
metadataApi.describeMetadata()
.then(function(response) {
let result = xmlParser.parse(response["body"]);
settingsUtil.setConfigValue(
"metadata.json",
result["soapenv:Envelope"]["soapenv:Body"]["describeMetadataResponse"]["result"]
);
.then( result => {
metadata.setMetaObjects(result);
})
.catch(err => {
console.error(err);
Expand Down
20 changes: 11 additions & 9 deletions src/settings/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import * as settingsUtil from "./settingsUtil";
export default class Metadata {
private static instance: Metadata;
private metaFileName = "metadata.json";
private metaObjects: any;

private constructor() {
this.metaObjects = settingsUtil.getConfig(
this.metaFileName
)["metadataObjects"];
}

public static getInstance() {
if (!Metadata.instance) {
Expand All @@ -21,11 +14,19 @@ export default class Metadata {
return Metadata.instance;
}

public setMetaObjects(metaObject: any) {
settingsUtil.setConfigValue(
"metadata.json", metaObject
);
}

/**
* Get metaobjects array
*/
public getMetaObjects() {
return this.metaObjects;
return settingsUtil.getConfig(
this.metaFileName
)["metadataObjects"];
}

/**
Expand All @@ -40,7 +41,8 @@ export default class Metadata {
* }
*/
public getMetaObject(metaFolder: string): any {
for (const metaObject of this.metaObjects) {
let metaobjects = this.getMetaObjects();
for (const metaObject of metaobjects) {
if (metaObject["directoryName"] === metaFolder) {
return metaObject;
}
Expand Down

0 comments on commit f9ac7af

Please sign in to comment.