Skip to content

Commit

Permalink
fix(submit_confirm_modal.ts): fix handleSubmit() method to correctly …
Browse files Browse the repository at this point in the history
…validate required fields before submitting

refactor(submit_confirm_modal.ts): extract createUI() method to improve code readability and maintainability
feat(submit_confirm_modal.ts): add support for displaying loading indicator while fetching community categories
feat(submit_confirm_modal.ts): add support for dynamically creating UI elements for community categories selection
  • Loading branch information
anpigon committed Mar 29, 2024
1 parent 42e1608 commit 587b04c
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/ui/submit_confirm_modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,13 @@ export class SubmitConfirmModal extends Modal {
}

async handleSubmit() {
if (!this.validateRequiredFields()) {
return;
if (this.validateRequiredFields()) {
this.callback(this.postData, this.postOptions);
this.close();
}

this.callback(this.postData, this.postOptions);
this.close();
}

async onOpen() {
const { contentEl } = this;
contentEl.classList?.add('steem-plugin');

contentEl.createEl('h2', { text: 'Publish to steemit' });

const loading = CustomLoadingComponent(contentEl);
const communityCategories = await this.getCommunityCategories();

createUI(contentEl: HTMLElement, communityCategories: Record<string, string>) {
// get my community categories
new Setting(contentEl)
.setName('Community')
Expand Down Expand Up @@ -127,7 +117,15 @@ export class SubmitConfirmModal extends Modal {
btn.setButtonText('Publish');
btn.onClick(() => this.handleSubmit());
});
}

async onOpen() {
const { contentEl } = this;
contentEl.classList?.add('steem-plugin');
contentEl.createEl('h2', { text: 'Publish to steemit' });
const loading = CustomLoadingComponent(contentEl);
const communityCategories = await this.getCommunityCategories();
this.createUI(contentEl, communityCategories);
loading.remove();
}

Expand Down

0 comments on commit 587b04c

Please sign in to comment.