Skip to content

Commit

Permalink
move getPathCodeSettings to constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ho-wan committed Jan 20, 2019
1 parent c930409 commit 23d9031
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/trello/TrelloUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export class TrelloUtils {
private API_KEY: string | undefined;
private API_TOKEN: string | undefined;
private FAVORITE_LIST_ID: string | undefined;
private tempTrelloFile: string;

constructor(context?: vscode.ExtensionContext) {
this.globalState = context ? context.globalState : {};
axios.defaults.baseURL = TRELLO_API_BASE_URL;
this.tempTrelloFile = new UserDataFolder().getPathCodeSettings() + TEMP_TRELLO_FILE_NAME || "";

this.getCredentials();
this.getFavoriteList();
Expand Down Expand Up @@ -341,13 +343,12 @@ export class TrelloUtils {
});
cardContent += cardCoverImageUrl ? `<img src="${cardCoverImageUrl}" alt="Image not found" />` : "";

// Get location of user's vs code folder to save temp markdown file
const tempTrelloFile = new UserDataFolder().getPathCodeSettings() + TEMP_TRELLO_FILE_NAME;
writeFile(tempTrelloFile, cardContent, err => {
// Write temp markdown file at user's vs code default settings directory
writeFile(this.tempTrelloFile, cardContent, err => {
if (err) {
vscode.window.showErrorMessage(`Error writing to temp file: ${err}`);
}
console.info(`✍ Writing to file: ${tempTrelloFile}`);
console.info(`✍ Writing to file: ${this.tempTrelloFile}`);
});

// open markdown file and preview view
Expand All @@ -359,7 +360,7 @@ export class TrelloUtils {
viewColumn = SETTING_CONFIG.DEFAULT_VIEW_COLUMN;
}
vscode.workspace
.openTextDocument(tempTrelloFile)
.openTextDocument(this.tempTrelloFile)
.then(doc => vscode.window.showTextDocument(doc, viewColumn, false))
.then(() => vscode.commands.executeCommand("markdown.showPreview"))
.then(() => vscode.commands.executeCommand("markdown.preview.toggleLock"));
Expand Down

0 comments on commit 23d9031

Please sign in to comment.