diff options
author | 2021-09-06 23:13:22 +0200 | |
---|---|---|
committer | 2021-09-06 23:13:22 +0200 | |
commit | 569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a (patch) | |
tree | 8d1cb94a56d60b9d726222277b7516fc59895613 /helpers | |
parent | 275bd1d0a9aea90696c145cf992d522a0d6b0aa8 (diff) | |
download | my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.gz my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.bz2 my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.zip |
added stadard linter
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/crypt.js | 2 | ||||
-rw-r--r-- | helpers/email.js | 3 | ||||
-rw-r--r-- | helpers/fetchJson.js | 4 | ||||
-rw-r--r-- | helpers/queue.js | 48 | ||||
-rw-r--r-- | helpers/saveFile.js | 4 | ||||
-rw-r--r-- | helpers/submitForm.js | 14 | ||||
-rw-r--r-- | helpers/windowActions.js | 20 |
7 files changed, 46 insertions, 49 deletions
diff --git a/helpers/crypt.js b/helpers/crypt.js index 5d3d79e..921d3f6 100644 --- a/helpers/crypt.js +++ b/helpers/crypt.js @@ -15,5 +15,5 @@ export const decrypt = (hash) => { const decipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.from(iv, 'hex')) const decrpyted = Buffer.concat([decipher.update(Buffer.from(content, 'hex')), decipher.final()]) - return decrpyted.toString(); + return decrpyted.toString() } diff --git a/helpers/email.js b/helpers/email.js index 30e95c8..52815f5 100644 --- a/helpers/email.js +++ b/helpers/email.js @@ -1,6 +1,5 @@ -import {t} from 'configs/translations' +import { t } from 'configs/translations' export const subject = l => t(l, 'mail_ver_subject') export const text = (l, key) => `${t(l, 'mail_ver_t1')}\n${t(l, 'mail_ver_t2')}\n\n${key}\n\n${t(l, 'mail_ver_t3')}` export const html = (l, key) => `<p>${t(l, 'mail_ver_t1')}<br/>${t(l, 'mail_ver_t2')}</p><p style="font-size: 150%;padding: 1em;border: 1px solid black">${key}</p><p>${t(l, 'mail_ver_t3')}</p></br>` - diff --git a/helpers/fetchJson.js b/helpers/fetchJson.js index 5db80b5..fda2fb5 100644 --- a/helpers/fetchJson.js +++ b/helpers/fetchJson.js @@ -1,4 +1,4 @@ -export default async function fetcher(...args) { +export default async function fetcher (...args) { try { const response = await fetch(...args) @@ -16,7 +16,7 @@ export default async function fetcher(...args) { throw error } catch (error) { if (!error.data) { - error.data = {message: error.message} + error.data = { message: error.message } } throw error } diff --git a/helpers/queue.js b/helpers/queue.js index 69e708a..6a9148d 100644 --- a/helpers/queue.js +++ b/helpers/queue.js @@ -1,7 +1,7 @@ class Queue { - static queue = []; - static pendingPromise = false; - static stop = false; + static queue = [] + static pendingPromise = false + static stop = false static enqueue(promise) { return new Promise((resolve, reject) => { @@ -9,44 +9,44 @@ class Queue { promise, resolve, reject - }); - this.dequeue(); - }); + }) + this.dequeue() + }) } static dequeue() { if (this.workingOnPromise) { - return false; + return false } if (this.stop) { - this.queue = []; - this.stop = false; - return; + this.queue = [] + this.stop = false + return } - const item = this.queue.shift(); + const item = this.queue.shift() if (!item) { - return false; + return false } try { - this.workingOnPromise = true; + this.workingOnPromise = true item .promise() .then((value) => { - this.workingOnPromise = false; - item.resolve(value); - this.dequeue(); + this.workingOnPromise = false + item.resolve(value) + this.dequeue() }) .catch((err) => { - this.workingOnPromise = false; - item.reject(err); - this.dequeue(); - }); + this.workingOnPromise = false + item.reject(err) + this.dequeue() + }) } catch (err) { - this.workingOnPromise = false; - item.reject(err); - this.dequeue(); + this.workingOnPromise = false + item.reject(err) + this.dequeue() } - return true; + return true } } diff --git a/helpers/saveFile.js b/helpers/saveFile.js index 83d46cb..83d3b28 100644 --- a/helpers/saveFile.js +++ b/helpers/saveFile.js @@ -1,8 +1,8 @@ const saveFile = (content, filename, type) => { const a = document.createElement('a') - const file = new Blob([content], {type}) + const file = new Blob([content], { type }) - a.href= URL.createObjectURL(file) + a.href = URL.createObjectURL(file) a.download = filename a.click() diff --git a/helpers/submitForm.js b/helpers/submitForm.js index 631c174..d67a7dc 100644 --- a/helpers/submitForm.js +++ b/helpers/submitForm.js @@ -5,9 +5,9 @@ const submitForm = async (e, url, mutateUser, setErrorMsg) => { const isRegister = url.includes('register') if ( - isRegister && e.currentTarget.password_confirm - && e.currentTarget.password_confirm.value - !== e.currentTarget.password.value + isRegister && e.currentTarget.password_confirm && + e.currentTarget.password_confirm.value !== + e.currentTarget.password.value ) { setErrorMsg('passwords_not_match') return @@ -19,13 +19,13 @@ const submitForm = async (e, url, mutateUser, setErrorMsg) => { email: e.currentTarget.email.value, password: e.currentTarget.password.value, ...(e.currentTarget.language - ? {language: e.currentTarget.language.value} + ? { language: e.currentTarget.language.value } : {} ), ...(e.currentTarget.theme - ? {theme: e.currentTarget.theme.value} + ? { theme: e.currentTarget.theme.value } : {} - ), + ) } try { @@ -33,7 +33,7 @@ const submitForm = async (e, url, mutateUser, setErrorMsg) => { await fetchJson(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(body), + body: JSON.stringify(body) }) ) } catch (err) { diff --git a/helpers/windowActions.js b/helpers/windowActions.js index b6d86b6..090e20a 100644 --- a/helpers/windowActions.js +++ b/helpers/windowActions.js @@ -1,9 +1,9 @@ -export const close = (appName, setApps) => {setApps(apps => apps.filter(a => a && a.name !== appName))} +export const close = (appName, setApps) => { setApps(apps => apps.filter(a => a && a.name !== appName)) } -export const open = ({appName, buttons, height, width}, setApps) => { +export const open = ({ appName, buttons, height, width }, setApps) => { setApps(apps => ( !apps.some(a => a.name === appName) - ? [...apps, {name: appName, min: false, max: false, height, width, pos: [], buttons}] + ? [...apps, { name: appName, min: false, max: false, height, width, pos: [], buttons }] : apps )) } @@ -12,7 +12,7 @@ export const focus = (appName, setApps) => { setApps(apps => { const i = apps.findIndex(a => a.name === appName) return i !== apps.length - 1 - ? [...apps.filter((_,n) => n !== i), apps[i]] + ? [...apps.filter((_, n) => n !== i), apps[i]] : apps }) } @@ -21,23 +21,22 @@ export const unfocus = (appName, setApps) => { setApps(apps => { const i = apps.findIndex(a => a.name === appName) return i !== 0 - ? [apps[i], ...apps.filter((_,n) => n !== i)] + ? [apps[i], ...apps.filter((_, n) => n !== i)] : apps }) } export const toggleMin = (appName, setApps) => { setApps(apps => ([ - ...apps.map(a => a.name === appName ? {...a, min: !a.min} : a ) + ...apps.map(a => a.name === appName ? { ...a, min: !a.min } : a) ])) unfocus(appName, setApps) } export const toggleMax = (appName, setApps) => setApps(apps => ([ - ...apps.map(a => a.name === appName ? {...a, max: !a.max} : a ) + ...apps.map(a => a.name === appName ? { ...a, max: !a.max } : a) ])) - export const move = (app, winRef, setApps) => { winRef.current.onmousedown = (event) => { if (!app.max && event.target.classList && event.target.classList.contains('window__title')) { @@ -46,12 +45,12 @@ export const move = (app, winRef, setApps) => { winRef.current.classList.add('moving') focus(app.name, setApps) - function moveAt(pageX, pageY) { + function moveAt (pageX, pageY) { const x = pageX - shiftX const y = pageY - shiftY - 32 setApps(apps => ([...apps.map(a => a.name === app.name - ? {...a, pos: [x + 'px', y < 0 ? 0 : y + 'px']} + ? { ...a, pos: [x + 'px', y < 0 ? 0 : y + 'px'] } : a )])) } @@ -72,4 +71,3 @@ export const move = (app, winRef, setApps) => { winRef.current.ondragstart = () => null } - |