mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 04:03:08 +02:00
refactor(general): use Date.now()
instead of creating a new Date
instance (#13671)
This commit is contained in:
parent
2f8fb105a5
commit
959cc8ff37
9 changed files with 13 additions and 13 deletions
|
@ -305,7 +305,7 @@ export class AccountMoveService {
|
||||||
let resultUser: MiLocalUser | MiRemoteUser | null = null;
|
let resultUser: MiLocalUser | MiRemoteUser | null = null;
|
||||||
|
|
||||||
if (this.userEntityService.isRemoteUser(dst)) {
|
if (this.userEntityService.isRemoteUser(dst)) {
|
||||||
if ((new Date()).getTime() - (dst.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
if (Date.now() - (dst.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
||||||
await this.apPersonService.updatePerson(dst.uri);
|
await this.apPersonService.updatePerson(dst.uri);
|
||||||
}
|
}
|
||||||
dst = await this.apPersonService.fetchPerson(dst.uri) ?? dst;
|
dst = await this.apPersonService.fetchPerson(dst.uri) ?? dst;
|
||||||
|
@ -321,7 +321,7 @@ export class AccountMoveService {
|
||||||
if (!src) continue; // oldAccountを探してもこのサーバーに存在しない場合はフォロー関係もないということなのでスルー
|
if (!src) continue; // oldAccountを探してもこのサーバーに存在しない場合はフォロー関係もないということなのでスルー
|
||||||
|
|
||||||
if (this.userEntityService.isRemoteUser(dst)) {
|
if (this.userEntityService.isRemoteUser(dst)) {
|
||||||
if ((new Date()).getTime() - (src.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
if (Date.now() - (src.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
||||||
await this.apPersonService.updatePerson(srcUri);
|
await this.apPersonService.updatePerson(srcUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ export class PushNotificationService implements OnApplicationShutdown {
|
||||||
type,
|
type,
|
||||||
body: (type === 'notification' || type === 'unreadAntennaNote') ? truncateBody(type, body) : body,
|
body: (type === 'notification' || type === 'unreadAntennaNote') ? truncateBody(type, body) : body,
|
||||||
userId,
|
userId,
|
||||||
dateTime: (new Date()).getTime(),
|
dateTime: Date.now(),
|
||||||
}), {
|
}), {
|
||||||
proxy: this.config.proxy,
|
proxy: this.config.proxy,
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -47,7 +47,7 @@ const invalid = Number.isNaN(_time);
|
||||||
const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
|
const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||||
const now = ref((props.origin ?? new Date()).getTime());
|
const now = ref(props.origin?.getTime() ?? Date.now());
|
||||||
const ago = computed(() => (now.value - _time) / 1000/*ms*/);
|
const ago = computed(() => (now.value - _time) / 1000/*ms*/);
|
||||||
|
|
||||||
const relative = computed<string>(() => {
|
const relative = computed<string>(() => {
|
||||||
|
@ -77,7 +77,7 @@ let tickId: number;
|
||||||
let currentInterval: number;
|
let currentInterval: number;
|
||||||
|
|
||||||
function tick() {
|
function tick() {
|
||||||
now.value = (new Date()).getTime();
|
now.value = Date.now();
|
||||||
const nextInterval = ago.value < 60 ? 10000 : ago.value < 3600 ? 60000 : 180000;
|
const nextInterval = ago.value < 60 ? 10000 : ago.value < 3600 ? 60000 : 180000;
|
||||||
|
|
||||||
if (currentInterval !== nextInterval) {
|
if (currentInterval !== nextInterval) {
|
||||||
|
|
|
@ -68,9 +68,9 @@ watch(showColon, (v) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const tick = () => {
|
const tick = () => {
|
||||||
const now = new Date();
|
const now = Date.now();
|
||||||
ss.value = Math.floor(now.getTime() / 1000).toString();
|
ss.value = Math.floor(now / 1000).toString();
|
||||||
ms.value = Math.floor(now.getTime() % 1000 / 10).toString().padStart(2, '0');
|
ms.value = Math.floor(now % 1000 / 10).toString().padStart(2, '0');
|
||||||
if (ss.value !== prevSec) showColon.value = true;
|
if (ss.value !== prevSec) showColon.value = true;
|
||||||
prevSec = ss.value;
|
prevSec = ss.value;
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,7 +76,7 @@ globalThis.addEventListener('push', ev => {
|
||||||
case 'notification':
|
case 'notification':
|
||||||
case 'unreadAntennaNote':
|
case 'unreadAntennaNote':
|
||||||
// 1日以上経過している場合は無視
|
// 1日以上経過している場合は無視
|
||||||
if ((new Date()).getTime() - data.dateTime > 1000 * 60 * 60 * 24) break;
|
if (Date.now() - data.dateTime > 1000 * 60 * 60 * 24) break;
|
||||||
|
|
||||||
return createNotification(data);
|
return createNotification(data);
|
||||||
case 'readAllNotifications':
|
case 'readAllNotifications':
|
||||||
|
|
Loading…
Reference in a new issue