Merge pull request 'fix(ui): prevent exceptions on other users' repo migration pages' (#4875) from solomonv/forgejo:fix-migration-guest-exception into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4875
Reviewed-by: Caesar Schinas <caesar@caesarschinas.com>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
Gusted 2024-08-24 23:49:20 +00:00
commit 4f54918381
2 changed files with 34 additions and 1 deletions

View file

@ -7,13 +7,14 @@ export function initRepoMigrationStatusChecker() {
const repoMigrating = document.getElementById('repo_migrating');
if (!repoMigrating) return;
document.getElementById('repo_migrating_retry').addEventListener('click', doMigrationRetry);
document.getElementById('repo_migrating_retry')?.addEventListener('click', doMigrationRetry);
const task = repoMigrating.getAttribute('data-migrating-task-id');
// returns true if the refresh still needs to be called after a while
const refresh = async () => {
const res = await GET(`${appSubUrl}/user/task/${task}`);
if (res.url.endsWith('/login')) return false; // stop refreshing if redirected to login
if (res.status !== 200) return true; // continue to refresh if network error occurs
const data = await res.json();