react to statusChanged event

pull/1861/head
Joseph Izang 3 years ago
parent 1bca4ce3c6
commit 27422c50d8
  1. 5
      libs/remix-ui/vertical-icons-panel/src/lib/components/OtherIcons.tsx
  2. 1
      libs/remix-ui/vertical-icons-panel/src/lib/reducers/iconBadgeReducer.ts
  3. 2
      libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx

@ -33,14 +33,15 @@ function OtherIcons ({ verticalIconsPlugin, itemContextAction, addActive, remove
Object.keys(verticalIconsPlugin.targetProfileForChange) Object.keys(verticalIconsPlugin.targetProfileForChange)
.filter(customFilter) .filter(customFilter)
.forEach(p => .forEach(p =>
verticalIconsPlugin.on(verticalIconsPlugin.targetProfileForChange[p].name, 'statusChanged', (iconStatus: IconStatus) => { verticalIconsPlugin.on(verticalIconsPlugin.targetProfileForChange[p].name, 'statusChanged', (evt: Event, iconStatus: IconStatus) => {
const action: IconBadgeReducerAction = { const action: IconBadgeReducerAction = {
type: verticalIconsPlugin.targetProfileForChange[p].name, type: verticalIconsPlugin.targetProfileForChange[p].name,
payload: { status: iconStatus, verticalIconPlugin: verticalIconsPlugin } payload: { status: iconStatus, verticalIconPlugin: verticalIconsPlugin }
} }
console.log('check the event payload', { evt })
dispatchStatusUpdate(action) dispatchStatusUpdate(action)
})) }))
}, []) }, [verticalIconsPlugin.targetProfileForChange, Object.keys(verticalIconsPlugin.targetProfileForChange).length])
return ( return (
<div id="otherIcons"> <div id="otherIcons">
{ {

@ -36,6 +36,7 @@ function setIconStatus (name: string, status: IconStatus) {
export function iconBadgeReducer (state: BadgeStatus, action: IconBadgeReducerAction) { export function iconBadgeReducer (state: BadgeStatus, action: IconBadgeReducerAction) {
const { status, ref, verticalIconPlugin } = action.payload const { status, ref, verticalIconPlugin } = action.payload
console.log('badge contains ', { status })
if (Object.keys(verticalIconPlugin.targetProfileForChange).includes(action.type)) { if (Object.keys(verticalIconPlugin.targetProfileForChange).includes(action.type)) {
const setStatus = setIconStatus(action.type, status) const setStatus = setIconStatus(action.type, status)
return setStatus return setStatus

@ -36,7 +36,6 @@ export function RemixUiVerticalIconsPanel ({
useEffect(() => { useEffect(() => {
const evaluateScrollability = (evt: any) => { const evaluateScrollability = (evt: any) => {
console.log('resize event answered by dispatch!')
dispatchScrollAction({ dispatchScrollAction({
type: 'resize', type: 'resize',
payload: { payload: {
@ -80,7 +79,6 @@ export function RemixUiVerticalIconsPanel ({
} }
function addActive (name: string) { function addActive (name: string) {
console.log('addactive has been called now.')
if (name === 'home') return if (name === 'home') return
const themeType = verticalIconsPlugin.registry.get('themeModule').api.currentTheme().quality const themeType = verticalIconsPlugin.registry.get('themeModule').api.currentTheme().quality
const invert = themeType === 'dark' ? 1 : 0 const invert = themeType === 'dark' ? 1 : 0

Loading…
Cancel
Save