@@ -18,6 +18,24 @@ import {
1818} from "../app-framework" ;
1919import { Icon , Gap } from "../components" ;
2020const { SiteName } = require ( "../customize" ) ;
21+ const HOUR_MS = 60 * 60 * 1000 ;
22+
23+ function formatTimeDelta ( ms : number | undefined ) : string {
24+ if ( ms == null || ! isFinite ( ms ) || ms <= 0 ) {
25+ return "soon" ;
26+ }
27+ const hours = ms / HOUR_MS ;
28+ if ( hours >= 48 ) {
29+ const days = Math . round ( hours / 24 ) ;
30+ return `in ${ days } day${ days === 1 ? "" : "s" } ` ;
31+ }
32+ if ( hours >= 1 ) {
33+ const rounded = Math . round ( hours * 10 ) / 10 ;
34+ return `in ${ rounded } hour${ rounded === 1 ? "" : "s" } ` ;
35+ }
36+ const minutes = Math . max ( 1 , Math . round ( ms / 60000 ) ) ;
37+ return `in ${ minutes } minute${ minutes === 1 ? "" : "s" } ` ;
38+ }
2139
2240interface Props {
2341 project_id : string ;
@@ -38,6 +56,8 @@ const AnonymousNameInput: React.FC<Props> = React.memo(({ project_id }) => {
3856 const project = useRedux ( [ "project_map" , project_id ] , "projects" ) ;
3957 const first_name = useTypedRedux ( "account" , "first_name" ) ;
4058 const last_name = useTypedRedux ( "account" , "last_name" ) ;
59+ const ephemeral = useTypedRedux ( "account" , "ephemeral" ) ;
60+ const created = useTypedRedux ( "account" , "created" ) ;
4161 const [ editingName , setEditingName ] = useState < boolean > ( false ) ;
4262 const actions = useActions ( "account" ) ;
4363 if ( first_name == null || last_name == null ) {
@@ -54,7 +74,18 @@ const AnonymousNameInput: React.FC<Props> = React.memo(({ project_id }) => {
5474 </ >
5575 ) ;
5676 let mesg ;
57- if ( ( project ?. get ( "users" ) ?. size ?? 1 ) <= 1 ) {
77+ if ( ephemeral ) {
78+ const expiresAt =
79+ created != null ? created . valueOf ( ) + ephemeral : Date . now ( ) + ephemeral ;
80+ const timeText = formatTimeDelta ( expiresAt - Date . now ( ) ) ;
81+ mesg = (
82+ < div >
83+ { icon }
84+ You are using < SiteName /> with an ephemeral account. This account will
85+ be deleted { timeText } .
86+ </ div >
87+ ) ;
88+ } else if ( ( project ?. get ( "users" ) ?. size ?? 1 ) <= 1 ) {
5889 // no need to encourage a name -- they are alone; also, emphasize
5990 // that they could lose their work:
6091 mesg = (
0 commit comments