forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(js,react): inbox custom bell unread count not updating (novuhq#6362)
- Loading branch information
Showing
21 changed files
with
942 additions
and
110 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { onCleanup, createEffect, ParentProps } from 'solid-js'; | ||
|
||
type ExternalElementMounterProps = ParentProps<{ | ||
render: (el: HTMLDivElement) => () => void; | ||
}>; | ||
|
||
export const ExternalElementRenderer = ({ render, ...rest }: ExternalElementMounterProps) => { | ||
let ref: HTMLDivElement; | ||
|
||
createEffect(() => { | ||
const unmount = render(ref); | ||
|
||
onCleanup(() => { | ||
unmount(); | ||
}); | ||
}); | ||
|
||
return ( | ||
<div | ||
ref={(el) => { | ||
ref = el; | ||
}} | ||
{...rest} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { Component, Show } from 'solid-js'; | ||
import { useTotalUnreadCount } from '../../../context'; | ||
import { BellMounter } from '../../../types'; | ||
import { ExternalElementMounter } from '../../ExternalElementMounter'; | ||
import { BellRenderer } from '../../../types'; | ||
import { ExternalElementRenderer } from '../../ExternalElementRenderer'; | ||
import { BellContainer } from './DefaultBellContainer'; | ||
|
||
type BellProps = { | ||
mountBell?: BellMounter; | ||
renderBell?: BellRenderer; | ||
}; | ||
/* This is also going to be exported as a separate component. Keep it pure. */ | ||
export const Bell: Component<BellProps> = (props) => { | ||
const { totalUnreadCount } = useTotalUnreadCount(); | ||
|
||
return ( | ||
<Show when={props.mountBell} fallback={<BellContainer unreadCount={totalUnreadCount()} />}> | ||
<ExternalElementMounter mount={(el) => props.mountBell!(el, totalUnreadCount())} /> | ||
<Show when={props.renderBell} fallback={<BellContainer unreadCount={totalUnreadCount()} />}> | ||
<ExternalElementRenderer render={(el) => props.renderBell!(el, totalUnreadCount())} /> | ||
</Show> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.