Skip to content

Commit 3545ba0

Browse files
committed
make UI use GET only when StreamArchives is enabled
1 parent 9142a38 commit 3545ba0

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

modules/templates/helper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ func NewFuncMap() template.FuncMap {
127127
"EnableTimetracking": func() bool {
128128
return setting.Service.EnableTimetracking
129129
},
130+
"StreamArchives": func() bool {
131+
return setting.Repository.StreamArchives
132+
},
130133
"DisableWebhooks": func() bool {
131134
return setting.DisableWebhooks
132135
},

templates/base/head_script.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
1717
pageData: {{.PageData}},
1818
notificationSettings: {{NotificationSettings}}, {{/*a map provided by NewFuncMap in helper.go*/}}
1919
enableTimeTracking: {{EnableTimetracking}},
20+
streamArchives: {{StreamArchives}},
2021
{{if or .Participants .Assignees .MentionableTeams}}
2122
mentionValues: Array.from(new Map([
2223
{{- range .Participants -}}

web_src/js/features/repo-common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ async function onDownloadArchive(e: DOMEvent<MouseEvent>) {
3232
}
3333

3434
export function initRepoArchiveLinks() {
35-
queryElems(document, 'a.archive-link[href]', (el) => el.addEventListener('click', onDownloadArchive));
35+
// when streaming is enabled, the links will work as-is without the need to wait until the archive is ready
36+
if (!window.config.streamArchives) {
37+
queryElems(document, 'a.archive-link[href]', (el) => el.addEventListener('click', onDownloadArchive));
38+
}
3639
}
3740

3841
export function initRepoActivityTopAuthorsChart() {

web_src/js/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type Config = {
2020
mentionValues?: MentionValue[],
2121
mermaidMaxSourceCharacters: number,
2222
i18n: Record<string, string>,
23+
streamArchives: boolean,
2324
}
2425

2526
export type IntervalId = ReturnType<typeof setInterval>;

web_src/js/vitest.setup.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type {Config} from "./types.ts";
2+
13
window.__webpack_public_path__ = '';
24

35
window.config = {
@@ -22,4 +24,5 @@ window.config = {
2224
],
2325
mermaidMaxSourceCharacters: 5000,
2426
i18n: {},
25-
};
27+
streamArchives: true,
28+
} satisfies Config;

0 commit comments

Comments
 (0)