Skip to content

Commit

Permalink
[FIX] Comments (#5)
Browse files Browse the repository at this point in the history
* Add comments

* Fix linting

* Fix Versions file
  • Loading branch information
4Source authored Mar 18, 2024
1 parent 8d5e35d commit f1583e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/modals/PluginDataModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PluginDataModal extends Modal {
.addText(text => text
.setPlaceholder('Username')
.onChange(value => {
// Assign value of this Setting an save it
// Assign value of this Setting
username = value;
}));

Expand All @@ -38,32 +38,37 @@ export class PluginDataModal extends Modal {
.addText(text => text
.setPlaceholder('Repository')
.onChange(value => {
// Assign value of this Setting an save it
// Assign value of this Setting
repository = value;
}));

new Setting(contentEl)
.addButton(button => button
.setButtonText('Save')
.onClick(async () => {
// Check username exist and is not empty
if (!username || username === '') {
new Notice('Github username cannot be empty!');
return;
}
// Check repository exist and is not empty
if (!repository || repository === '') {
new Notice('Github repository cannot be empty!');
return;
}
// Check the repo matches the pattern
const repo = `${username}/${repository}`;
if (!repositoryRegEx.test(repo)) {
new Notice('Github <username>/<repository> do not match the pattern!');
return;
}
// Check a manifest could be fetched
const manifest = await fetchManifest(repo);
if (!manifest) {
new Notice('Github repository could not be found!');
return;
}
// check there are releases for the repo
const releases = await fetchReleases(repo);
if (!releases || releases.length <= 0) {
new Notice('No releases found for this plugin. May it do not have any.');
Expand Down
1 change: 1 addition & 0 deletions src/modals/PluginTroubleshootingModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class PluginTroubleshootingModal extends Modal {
let releases: Partial<Release>[] | undefined;
let hasReleases = false;

// Debonce text input
const updateRepo = debounce(() => {
this.pluginInfo.repo = `${username}/${repository}`;
this.update();
Expand Down
4 changes: 3 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"0.0.0": "0.15.0"
}

0 comments on commit f1583e2

Please sign in to comment.