diff options
| author | Johann150 <johann.galle@protonmail.com> | 2022-05-29 08:15:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-29 15:15:52 +0900 |
| commit | 804fa33535baa9e5cdf49070a50a555cf2c3b1ea (patch) | |
| tree | 61b2a5c705af743c8dff1cf77764e0bcb76f1820 /packages/client/src | |
| parent | fix(client): Vite related boot mechanism revision (#8753) (diff) | |
| download | sharkey-804fa33535baa9e5cdf49070a50a555cf2c3b1ea.tar.gz sharkey-804fa33535baa9e5cdf49070a50a555cf2c3b1ea.tar.bz2 sharkey-804fa33535baa9e5cdf49070a50a555cf2c3b1ea.zip | |
refactor: improve code quality (#8751)
* remove unnecessary if
`Array.prototype.some` already returns a boolean so an if to return
true or false is completely unnecessary in this case.
* perf: use count instead of find
When using `count` instead of `findOneBy`, the data is not
unnecessarily loaded.
* remove duplicate null check
The variable is checked for null in the lines above and the function
returns if so. Therefore, it can not be null at this point.
* simplify `getJsonSchema`
Because the assigned value is `null` and the used keys are only
shallow, use of `nestedProperty.set` seems inappropriate. Because the
value is not read, the initial for loop can be replaced by a `for..in`
loop.
Since all keys will be assigned `null`, the condition of the ternary
expression in the nested function will always be true. Therefore the
recursion case will never happen. With this the nested function can be
eliminated.
* remove duplicate condition
The code above already checks `dragging` and returns if it is truthy.
Checking it again later is therefore unnecessary.
To make this more obvious the `return` is removed in favour of using
an if...else construct.
* remove impossible "unknown" time
The `ago` variable will always be a number and all non-negative numbers
are already covered by other cases, the negative case is handled with
`future` so there is no case when `unkown` could be achieved.
Diffstat (limited to 'packages/client/src')
| -rw-r--r-- | packages/client/src/components/global/time.vue | 3 | ||||
| -rw-r--r-- | packages/client/src/ui/deck/column.vue | 11 |
2 files changed, 6 insertions, 8 deletions
diff --git a/packages/client/src/components/global/time.vue b/packages/client/src/components/global/time.vue index 02351deb5f..a7f142f961 100644 --- a/packages/client/src/components/global/time.vue +++ b/packages/client/src/components/global/time.vue @@ -32,8 +32,7 @@ const relative = $computed(() => { ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) : ago >= 10 ? i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) : ago >= -1 ? i18n.ts._ago.justNow : - ago < -1 ? i18n.ts._ago.future : - i18n.ts._ago.unknown); + i18n.ts._ago.future); }); function tick() { diff --git a/packages/client/src/ui/deck/column.vue b/packages/client/src/ui/deck/column.vue index fbaea64f56..31063a753d 100644 --- a/packages/client/src/ui/deck/column.vue +++ b/packages/client/src/ui/deck/column.vue @@ -213,14 +213,13 @@ function onDragover(ev) { if (dragging) { // 自分自身にはドロップさせない ev.dataTransfer.dropEffect = 'none'; - return; - } - - const isDeckColumn = ev.dataTransfer.types[0] === _DATA_TRANSFER_DECK_COLUMN_; + } else { + const isDeckColumn = ev.dataTransfer.types[0] === _DATA_TRANSFER_DECK_COLUMN_; - ev.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none'; + ev.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none'; - if (!dragging && isDeckColumn) draghover = true; + if (isDeckColumn) draghover = true; + } } function onDragleave() { |