mirror of
https://github.com/utterance/utterances.git
synced 2024-09-11 07:15:28 +03:00
async/await
This commit is contained in:
parent
d7805caecf
commit
569d161be5
@ -44,34 +44,27 @@ function bootstrap(issue: Issue | null, user: User | null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const submit = (markdown: string) => {
|
||||
const submit = async (markdown: string) => {
|
||||
if (user) {
|
||||
let commentPromise: Promise<IssueComment>;
|
||||
if (issue) {
|
||||
commentPromise = postComment(issue.number, markdown);
|
||||
} else {
|
||||
commentPromise = createIssue(
|
||||
if (!issue) {
|
||||
issue = await createIssue(
|
||||
page.issueTerm as string,
|
||||
page.url,
|
||||
page.title,
|
||||
page.description
|
||||
).then(newIssue => {
|
||||
issue = newIssue;
|
||||
timeline.setIssue(issue);
|
||||
return postComment(issue.number, markdown);
|
||||
});
|
||||
);
|
||||
timeline.setIssue(issue);
|
||||
}
|
||||
return commentPromise.then(comment => {
|
||||
timeline.appendComment(comment);
|
||||
newCommentComponent.clear();
|
||||
});
|
||||
const comment = await postComment(issue.number, markdown);
|
||||
timeline.appendComment(comment);
|
||||
newCommentComponent.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
return login().then(() => loadUser()).then(u => {
|
||||
user = u;
|
||||
timeline.setUser(user);
|
||||
newCommentComponent.setUser(user);
|
||||
});
|
||||
await login();
|
||||
user = await loadUser();
|
||||
timeline.setUser(user);
|
||||
newCommentComponent.setUser(user);
|
||||
};
|
||||
|
||||
const newCommentComponent = new NewCommentComponent(user, submit);
|
||||
|
Loading…
Reference in New Issue
Block a user