@@ -11,9 +11,11 @@ import utc from "dayjs/plugin/utc";
11
11
import timezone from "dayjs/plugin/timezone" ;
12
12
import advancedFormat from "dayjs/plugin/advancedFormat" ;
13
13
import { useUserLoader } from "./hooks/use-user-loader" ;
14
+ import { getGitpodService } from "./service/service" ;
15
+ import { deepMerge } from "./utils" ;
14
16
15
17
const KEY_APP_DISMISSED_NOTIFICATIONS = "gitpod-app-notifications-dismissed" ;
16
- const PRIVACY_POLICY_LAST_UPDATED = "09/25/ 2023" ;
18
+ const PRIVACY_POLICY_LAST_UPDATED = "2023-09-26 " ;
17
19
18
20
interface Notification {
19
21
id : string ;
@@ -33,16 +35,21 @@ export function localizedTime(dateStr: string): JSX.Element {
33
35
}
34
36
35
37
function formatDate ( dateString : string ) : JSX . Element {
36
- const formatted = dayjs . utc ( dateString ) . local ( ) . format ( "LL " ) ;
38
+ const formatted = dayjs . utc ( dateString ) . local ( ) . format ( "MMMM D, YYYY " ) ;
37
39
return < time dateTime = { dateString } > { formatted } </ time > ;
38
40
}
39
41
40
42
const UPDATED_PRIVACY_POLICY : Notification = {
41
43
id : "privacy-policy-update" ,
42
44
type : "info" ,
43
45
preventDismiss : true ,
44
- onClose : ( ) => {
46
+ onClose : async ( ) => {
45
47
console . error ( "Well... happy for you" ) ;
48
+ const userUpdates = { additionalData : { profile : { acceptedPrivacyPolicyDate : dayjs ( ) . toISOString ( ) } } } ;
49
+ const previousUser = await getGitpodService ( ) . server . getLoggedInUser ( ) ;
50
+ const user = await getGitpodService ( ) . server . updateLoggedInUser ( deepMerge ( previousUser , userUpdates ) ) ;
51
+
52
+ console . log ( user ) ;
46
53
} ,
47
54
message : (
48
55
< span className = "text-md" >
@@ -61,8 +68,11 @@ export function AppNotifications() {
61
68
62
69
useEffect ( ( ) => {
63
70
const notifications = [ ] ;
64
- if ( ! loading && user ?. additionalData ) {
65
- if ( new Date ( PRIVACY_POLICY_LAST_UPDATED ) > new Date ( user . additionalData . acceptedPrivacyPoliceDate ) ) {
71
+ if ( ! loading && user ?. additionalData ?. profile ) {
72
+ if (
73
+ ! user . additionalData . profile . acceptedPrivacyPolicyDate ||
74
+ new Date ( PRIVACY_POLICY_LAST_UPDATED ) > new Date ( user . additionalData . profile ?. acceptedPrivacyPolicyDate )
75
+ ) {
66
76
notifications . push ( UPDATED_PRIVACY_POLICY ) ;
67
77
}
68
78
}
0 commit comments