iceshrimp/packages/backend/src/remote/activitypub/renderer
Johann150 ec47b46423 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.
2022-05-29 15:15:52 +09:00
..
accept.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
add.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
announce.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
block.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
create.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
delete.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
document.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
emoji.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
flag.ts refactor: fix type 2022-04-17 13:14:29 +09:00
follow-relay.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
follow-user.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
follow.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
hashtag.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
image.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
index.ts refactor: improve code quality (#8751) 2022-05-29 15:15:52 +09:00
key.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
like.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
mention.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
note.ts refactor 2022-04-17 21:01:02 +09:00
ordered-collection-page.ts fix lint 2021-12-09 23:58:30 +09:00
ordered-collection.ts refactor 2022-02-03 21:20:25 +09:00
person.ts refactor: migrate to typeorm 3.0 (#8443) 2022-03-26 15:34:00 +09:00
question.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
read.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
reject.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
remove.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
tombstone.ts fix lint 2021-12-09 23:58:30 +09:00
undo.ts Use unique id for Undo (#8434) 2022-03-22 00:39:00 +09:00
update.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
vote.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00