feat: Improve translations, fade inactive collection members

This commit is contained in:
Tom Moor
2022-09-13 08:47:41 +01:00
parent 6502aff4ef
commit 7d92b60e97
5 changed files with 73 additions and 12 deletions

View File

@@ -1,4 +1,6 @@
import { subMinutes } from "date-fns";
import { computed, observable } from "mobx";
import { now } from "mobx-utils";
import type { Role } from "@shared/types";
import ParanoidModel from "./ParanoidModel";
import Field from "./decorators/Field";
@@ -39,6 +41,17 @@ class User extends ParanoidModel {
return !this.lastActiveAt;
}
/**
* Whether the user has been recently active. Recently is currently defined
* as within the last 5 minutes.
*
* @returns true if the user has been active recently
*/
@computed
get isRecentlyActive(): boolean {
return new Date(this.lastActiveAt) > subMinutes(now(10000), 5);
}
@computed
get role(): Role {
if (this.isAdmin) {