Merge pull request '[GITEA] Limit amount of javascript errors being shown' (#2175) from gusted/forgejo-wall-of-errors into forgejo-dependency

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2175
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Gusted 2024-01-19 21:23:06 +00:00
commit 05bc80633d

View file

@ -8,6 +8,8 @@ __webpack_public_path__ = `${window.config?.assetUrlPrefix ?? '/assets'}/`;
export function showGlobalErrorMessage(msg) { export function showGlobalErrorMessage(msg) {
const pageContent = document.querySelector('.page-content'); const pageContent = document.querySelector('.page-content');
if (!pageContent) return; if (!pageContent) return;
// Prevent a wall of errors being presented to the user.
if (document.querySelectorAll('.js-global-error').length >= 3) return;
const el = document.createElement('div'); const el = document.createElement('div');
el.innerHTML = `<div class="ui container negative message center aligned js-global-error" style="white-space: pre-line;"></div>`; el.innerHTML = `<div class="ui container negative message center aligned js-global-error" style="white-space: pre-line;"></div>`;
el.childNodes[0].textContent = msg; el.childNodes[0].textContent = msg;