diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-11-09 17:27:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 17:27:25 +0800 |
commit | bb71ceeeb24a7d3e768ace8075b7dcc5c13713df (patch) | |
tree | f06b659609893ecafff60a0772b31dbf83d51412 /web_src/js/index.js | |
parent | 3a693bd18c6274b62aa7bcde69e9a0d86e43c534 (diff) | |
download | gitea-bb71ceeeb24a7d3e768ace8075b7dcc5c13713df.tar.gz gitea-bb71ceeeb24a7d3e768ace8075b7dcc5c13713df.zip |
Improve async/await usage, and sort init calls in `index.js` (#17386)
* clean up async/await, and sort init calls in `index.js
* use `const _promise` to indicate that we do not need await an async function
Diffstat (limited to 'web_src/js/index.js')
-rw-r--r-- | web_src/js/index.js | 147 |
1 files changed, 75 insertions, 72 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js index a3bd35175e..957a0d9e8a 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -7,27 +7,25 @@ import {initDashboardRepoList} from './components/DashboardRepoList.js'; import attachTribute from './features/tribute.js'; import initGlobalCopyToClipboardListener from './features/clipboard.js'; import initContextPopups from './features/contextpopup.js'; -import initGitGraph from './features/gitgraph.js'; +import initRepoGraphGit from './features/repo-graph.js'; import initHeatmap from './features/heatmap.js'; import initImageDiff from './features/imagediff.js'; -import initMigration from './features/migration.js'; -import initProject from './features/projects.js'; +import initRepoMigration from './features/repo-migration.js'; +import initRepoProject from './features/repo-projects.js'; import initServiceWorker from './features/serviceworker.js'; import initTableSort from './features/tablesort.js'; import {initAdminUserListSearchForm} from './features/admin-users.js'; import {initMarkupAnchors} from './markup/anchors.js'; import {initNotificationCount, initNotificationsTable} from './features/notification.js'; -import {initLastCommitLoader} from './features/lastcommitloader.js'; -import {initIssueContentHistory} from './features/issue-content-history.js'; +import {initRepoIssueContentHistory} from './features/repo-issue-content.js'; import {initStopwatch} from './features/stopwatch.js'; -import {initDiffShowMore} from './features/diff.js'; import {initCommentContent, initMarkupContent} from './markup/content.js'; import {initUserAuthLinkAccountView, initUserAuthOauth2} from './features/user-auth.js'; import { initRepoDiffConversationForm, initRepoDiffFileViewToggle, - initRepoDiffReviewButton, + initRepoDiffReviewButton, initRepoDiffShowMore, } from './features/repo-diff.js'; import { initRepoIssueDue, @@ -38,7 +36,7 @@ import { initRepoPullRequestMergeInstruction, initRepoPullRequestReview, } from './features/repo-issue.js'; -import {initRepoCommitButton} from './features/repo-commit.js'; +import {initRepoCommitButton, initRepoCommitLastCommitLoader} from './features/repo-commit.js'; import { initFootLanguageMenu, initGlobalButtonClickOnEnter, @@ -68,9 +66,9 @@ import {initOrgTeamSearchRepoBox, initOrgTeamSettings} from './features/org-team import {initUserAuthU2fAuth, initUserAuthU2fRegister} from './features/user-auth-u2f.js'; import {initRepoRelease, initRepoReleaseEditor} from './features/repo-release.js'; import {initRepoEditor} from './features/repo-editor.js'; -import {initSearchUserBox} from './features/comp/SearchUserBox.js'; +import {initCompSearchUserBox} from './features/comp/SearchUserBox.js'; import {initInstall} from './features/install.js'; -import {initWebHookEditor} from './features/comp/WebHookEditor.js'; +import {initCompWebHookEditor} from './features/comp/WebHookEditor.js'; import {initCommonIssue} from './features/common-issue.js'; import {initRepoBranchButton} from './features/repo-branch.js'; import {initCommonOrganization} from './features/common-organization.js'; @@ -82,85 +80,90 @@ $.fn.tab.settings.silent = true; initVueEnv(); -$(document).ready(async () => { +$(document).ready(() => { initGlobalCommon(); + + initGlobalButtonClickOnEnter(); + initGlobalButtons(); + initGlobalCopyToClipboardListener(); initGlobalDropzone(); + initGlobalEnterQuickSubmit(); + initGlobalFormDirtyLeaveConfirm(); initGlobalLinkActions(); - initGlobalButtons(); - initRepoBranchButton(); + + attachTribute(document.querySelectorAll('#content, .emoji-input')); initCommonIssue(); + initCommonOrganization(); - initSearchUserBox(); - initRepoSettingSearchTeamBox(); - initOrgTeamSearchRepoBox(); + initCompSearchUserBox(); + initCompWebHookEditor(); - initGlobalButtonClickOnEnter(); - initMarkupAnchors(); - initCommentContent(); - initRepoCommentForm(); initInstall(); - initRepoArchiveLinks(); - initRepository(); - initMigration(); - initRepoWikiForm(); - initRepoEditor(); - initCommonOrganization(); - initWebHookEditor(); + + initHeadNavbarContentToggle(); + initFootLanguageMenu(); + + initCommentContent(); + initContextPopups(); + initHeatmap(); + initImageDiff(); + initMarkupAnchors(); + initMarkupContent(); + initServiceWorker(); + initSshKeyFormParser(); + initStopwatch(); + initTableSort(); + initAdminCommon(); - initRepoCodeView(); - initRepoActivityTopAuthorsChart(); + initAdminEmails(); + initAdminUserListSearchForm(); + initDashboardRepoList(); + + initNotificationCount(); + initNotificationsTable(); + + initOrgTeamSearchRepoBox(); initOrgTeamSettings(); - initGlobalEnterQuickSubmit(); - initHeadNavbarContentToggle(); - initFootLanguageMenu(); - initRepoTopicBar(); - initUserAuthU2fAuth(); - initUserAuthU2fRegister(); + + initRepoActivityTopAuthorsChart(); + initRepoArchiveLinks(); + initRepoBranchButton(); + initRepoCodeView(); + initRepoCommentForm(); + initRepoCommitButton(); + initRepoCommitLastCommitLoader(); + initRepoDiffConversationForm(); + initRepoDiffFileViewToggle(); + initRepoDiffReviewButton(); + initRepoDiffShowMore(); + initRepoEditor(); + initRepoGraphGit(); + initRepoIssueContentHistory(); + initRepoIssueDue(); initRepoIssueList(); + initRepoIssueReferenceRepositorySearch(); initRepoIssueTimeTracking(); - initRepoIssueDue(); initRepoIssueWipTitle(); - initRepoPullRequestReview(); + initRepoMigration(); initRepoMigrationStatusChecker(); - initRepoTemplateSearch(); - initRepoIssueReferenceRepositorySearch(); - initContextPopups(); - initTableSort(); - initNotificationsTable(); - initLastCommitLoader(); + initRepoProject(); initRepoPullRequestMergeInstruction(); - initRepoDiffFileViewToggle(); - initRepoReleaseEditor(); + initRepoPullRequestReview(); initRepoRelease(); - initDiffShowMore(); - initIssueContentHistory(); - initAdminUserListSearchForm(); - initGlobalCopyToClipboardListener(); - initUserAuthOauth2(); - initRepoDiffReviewButton(); - initRepoCommitButton(); - initAdminEmails(); - initGlobalEnterQuickSubmit(); - initSshKeyFormParser(); - initGlobalFormDirtyLeaveConfirm(); - initUserSettings(); + initRepoReleaseEditor(); + initRepoSettingGitHook(); + initRepoSettingSearchTeamBox(); initRepoSettingsCollaboration(); - initUserAuthLinkAccountView(); - initRepoDiffConversationForm(); + initRepoTemplateSearch(); + initRepoTopicBar(); + initRepoWikiForm(); + initRepository(); - // parallel init of async loaded features - await Promise.all([ - attachTribute(document.querySelectorAll('#content, .emoji-input')), - initGitGraph(), - initHeatmap(), - initProject(), - initServiceWorker(), - initNotificationCount(), - initStopwatch(), - initMarkupContent(), - initRepoSettingGitHook(), - initImageDiff(), - ]); + initUserAuthLinkAccountView(); + initUserAuthOauth2(); + initUserAuthU2fAuth(); + initUserAuthU2fRegister(); + initUserSettings(); }); |