From b8b2a86374c7d70d1a929a3e11001ea044818ed6 Mon Sep 17 00:00:00 2001 From: MickaelK Date: Fri, 20 Oct 2023 20:16:39 +1100 Subject: [PATCH] chore (cleanup): cleanup before release --- .gitignore | 12 ++++++++++-- public/components/icon.js | 2 +- public/lib/ajax.js | 8 +------- public/lib/skeleton/router.js | 2 +- public/tsconfig.json | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 public/tsconfig.json diff --git a/.gitignore b/.gitignore index 9c634ad8..93037c02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ +.sass-cache dist/ *_generated.go test/ @@ -18,7 +19,14 @@ package-lock.json *_test.go cover.* www -*.test.js -__snapshots__ .gitignore + + +# frontend +public/**/*.test.js +public/**/__snapshots__ +public/jest.setup.js +public/package.json +public/README.org + filestash-enterprise \ No newline at end of file diff --git a/public/components/icon.js b/public/components/icon.js index 9b264ecb..d025c35e 100644 --- a/public/components/icon.js +++ b/public/components/icon.js @@ -6,7 +6,7 @@ class Icon extends window.HTMLElement { attributeChangedCallback() { const alt = this.getAttribute("name"); const img = this._mapOfIcon(alt); - requestAnimationFrame(() => { + window.requestAnimationFrame(() => { this.innerHTML = this.render({ alt, img }); }); } diff --git a/public/lib/ajax.js b/public/lib/ajax.js index 9618fffc..726e3b42 100644 --- a/public/lib/ajax.js +++ b/public/lib/ajax.js @@ -45,7 +45,7 @@ function processError(xhr, err) { if (window.navigator.onLine === false) { return new AjaxError("Connection Lost", err, "NO_INTERNET"); } - switch (xhr?.status) { + switch (parseInt(xhr?.status)) { case 500: return new AjaxError( message || "Oups something went wrong with our servers", @@ -72,12 +72,6 @@ function processError(xhr, err) { err, "BAD_GATEWAY" ); case 409: - if (response.error_summary) { // dropbox way to say doesn't exist - return new AjaxError( - "Doesn't exist", - err, "UNKNOWN_PATH" - ); - } return new AjaxError( message || "Oups you just ran into a conflict", err, "CONFLICT" diff --git a/public/lib/skeleton/router.js b/public/lib/skeleton/router.js index 83e1b6ab..dd098057 100644 --- a/public/lib/skeleton/router.js +++ b/public/lib/skeleton/router.js @@ -29,7 +29,7 @@ export function currentRoute(r, notFoundRoute) { return r[routeKey]; } } - return r[notFoundRoute]; + return r[notFoundRoute] || null; } function _getHref($node, $root) { diff --git a/public/tsconfig.json b/public/tsconfig.json new file mode 100644 index 00000000..0573d3ba --- /dev/null +++ b/public/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "noEmit": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noUncheckedIndexedAccess": true, + "strictNullChecks": true, + "strictPropertyInitialization": true, + "strictBindCallApply": true, + "strictFunctionTypes": true, + "strict": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "lib": [ + "dom", + "dom.iterable", + "es2022" + ], + "module": "es2022", + "target": "es2022", + "typeRoots": [] + }, + "input": ["pages/ctrl_boot.d.ts", "pages/*.js"], + "exclude": [ + "**/*.test.js", "worker/sw_cache.js", + "coverage", "jest.setup.js" + ] +}