Skip to content

Commit

Permalink
#102 - Fix on metadata update
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Sep 15, 2021
1 parent 2758c94 commit b072b92
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/webview/ExplorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,26 @@ export class ExplorerView implements WebviewViewProvider, Disposable {
* @param metadata
*/
public pushMetadata(metadata: any) {
const config = SettingsHelper.getConfig();
const commaSeparated = config.get<string[]>(SETTING_COMMA_SEPARATED_FIELDS);

const articleDetails = this.getArticleDetails();

if (articleDetails) {
metadata.articleDetails = articleDetails;
}

let updatedMetadata = Object.assign({}, metadata);
if (commaSeparated) {
for (const key of commaSeparated) {
if (updatedMetadata[key] && typeof updatedMetadata[key] === "string") {
updatedMetadata[key] = updatedMetadata[key].split(",").map((s: string) => s.trim());
}
}
}

this.postWebviewMessage({ command: Command.metadata, data: {
...metadata
...updatedMetadata
}});
}

Expand Down

0 comments on commit b072b92

Please sign in to comment.