Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/authentication/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @baseapp-frontend/authentication

## 4.0.4

### Patch Changes

- Make sure the log out listener is loaded only once in useCurrentProfile

## 4.0.3

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use client'

import { useCallback, useEffect } from 'react'

import {
LOGOUT_EVENT,
ServerSideRenderingOption,
Expand All @@ -27,6 +25,17 @@ const initialProfile = getProfileFromCookie()

export const profileAtom = atom<MinimalProfile | null>(initialProfile)

profileAtom.onMount = (setAtom) => {
const removeCurrentProfile = () => {
setAtom(null)
removeCookie(CURRENT_PROFILE_KEY)
}
eventEmitter.on(LOGOUT_EVENT, removeCurrentProfile)
return () => {
eventEmitter.off(LOGOUT_EVENT, removeCurrentProfile)
}
}

/**
* By using `useCurrentProfile` with the `noSSR` option set to `false`, causes Next.js to dynamically render the affected pages, instead of statically rendering them.
*/
Expand Down Expand Up @@ -54,15 +63,6 @@ const useCurrentProfile = ({ noSSR = true }: ServerSideRenderingOption = {}) =>
}
}

const removeCurrentProfile = useCallback(() => setCurrentProfile(null), [])

useEffect(() => {
eventEmitter.on(LOGOUT_EVENT, removeCurrentProfile)
return () => {
eventEmitter.off(LOGOUT_EVENT, removeCurrentProfile)
}
}, [])

if (isSSR) {
return {
currentProfile: getProfileFromCookie({ noSSR }),
Expand Down
7 changes: 7 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @baseapp-frontend/components

## 0.0.25

### Patch Changes

- Updated dependencies
- @baseapp-frontend/authentication@4.0.4

## 0.0.24

### Patch Changes
Expand Down
Loading