Skip to content

Commit 4e7a81f

Browse files
committed
small fix for consistency
1 parent d5db8ae commit 4e7a81f

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed

src/webviews/components/issue/CreateIssuePage.tsx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const IconValue = (props: any) => (
6565
export default class CreateIssuePage extends AbstractIssueEditorPage<Emit, Accept, {}, ViewState> {
6666
private advancedFields: FieldUI[] = [];
6767
private commonFields: FieldUI[] = [];
68+
private attachingInProgress: boolean;
6869

6970
getProjectKey(): string {
7071
return this.state.fieldValues['project'].key;
@@ -191,22 +192,29 @@ export default class CreateIssuePage extends AbstractIssueEditorPage<Emit, Accep
191192
};
192193

193194
protected handleInlineAttachments = async (fieldkey: string, newValue: any) => {
195+
if (this.attachingInProgress) {
196+
return;
197+
}
198+
194199
if (Array.isArray(newValue) && newValue.length > 0) {
195-
readFilesContentAsync(newValue).then((filesWithContent) => {
196-
const serFiles = filesWithContent.map((file) => {
197-
return {
198-
lastModified: file.lastModified,
199-
lastModifiedDate: (file as any).lastModifiedDate,
200-
name: file.name,
201-
size: file.size,
202-
type: file.type,
203-
path: (file as any).path,
204-
fileContent: file.fileContent,
205-
};
206-
});
207-
208-
this.setState({ fieldValues: { ...this.state.fieldValues, ...{ [fieldkey]: serFiles } } });
209-
});
200+
this.attachingInProgress = true;
201+
readFilesContentAsync(newValue)
202+
.then((filesWithContent) => {
203+
const serFiles = filesWithContent.map((file) => {
204+
return {
205+
lastModified: file.lastModified,
206+
lastModifiedDate: (file as any).lastModifiedDate,
207+
name: file.name,
208+
size: file.size,
209+
type: file.type,
210+
path: (file as any).path,
211+
fileContent: file.fileContent,
212+
};
213+
});
214+
215+
this.setState({ fieldValues: { ...this.state.fieldValues, ...{ [fieldkey]: serFiles } } });
216+
})
217+
.finally(() => this.attachingInProgress = false);
210218
}
211219
};
212220

src/webviews/components/issue/JiraIssuePage.tsx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -392,27 +392,28 @@ export default class JiraIssuePage extends AbstractIssueEditorPage<Emit, Accept,
392392
}
393393
this.attachingInProgress = true;
394394

395-
readFilesContentAsync(files).then((filesWithContent) => {
396-
this.setState({ currentInlineDialog: '', isSomethingLoading: false, loadingField: 'attachment' });
397-
const serFiles = filesWithContent.map((file) => {
398-
return {
399-
lastModified: file.lastModified,
400-
lastModifiedDate: (file as any).lastModifiedDate,
401-
name: file.name,
402-
size: file.size,
403-
type: file.type,
404-
path: (file as any).path,
405-
fileContent: file.fileContent,
406-
};
407-
});
408-
this.postMessage({
409-
action: 'addAttachments',
410-
site: this.state.siteDetails,
411-
issueKey: this.state.key,
412-
files: serFiles,
413-
});
414-
this.attachingInProgress = false;
415-
});
395+
readFilesContentAsync(files)
396+
.then((filesWithContent) => {
397+
this.setState({ currentInlineDialog: '', isSomethingLoading: false, loadingField: 'attachment' });
398+
const serFiles = filesWithContent.map((file) => {
399+
return {
400+
lastModified: file.lastModified,
401+
lastModifiedDate: (file as any).lastModifiedDate,
402+
name: file.name,
403+
size: file.size,
404+
type: file.type,
405+
path: (file as any).path,
406+
fileContent: file.fileContent,
407+
};
408+
});
409+
this.postMessage({
410+
action: 'addAttachments',
411+
site: this.state.siteDetails,
412+
issueKey: this.state.key,
413+
files: serFiles,
414+
});
415+
})
416+
.finally(() => this.attachingInProgress = false);
416417
};
417418

418419
handleDeleteAttachment = (file: any) => {

0 commit comments

Comments
 (0)