Skip to content

Commit

Permalink
Merge pull request #282 from helxplatform/fix/activity-monitor-remove…
Browse files Browse the repository at this point in the history
…d-app-bug

Add extra constraint to fully fix activity monitor removed app bug hopefully
  • Loading branch information
frostyfan109 authored Oct 25, 2023
2 parents 7ef07ed + 3c912cd commit faebc23
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/components/side-panel/side-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ const ActivityLog = ({ events, setShowEventInfo }) => {
const { appSpecs } = useActivity()

const [collapsed, setCollapsed] = useState(true)
const cleanedEvents = useMemo(() => events.filter((event) => {
// If an event exists for an app that has been removed from
// the available apps list, then we need to remove that event.
return appSpecs.hasOwnProperty(event.data.appId)
}), [events, appSpecs])
const [latestActivity, ...otherActivities] = useMemo(() => cleanedEvents, [cleanedEvents])
const [latestActivity, ...otherActivities] = useMemo(() => events, [events])

return (
<Collapse
Expand Down Expand Up @@ -156,18 +151,23 @@ const ActivityEntry = ({ event, full, setShowEventInfo }) => {
}

export const SidePanel = () => {
const { appActivityCache, clearActivity } = useActivity();
const { appActivityCache, appSpecs, clearActivity } = useActivity();
const { wsApi } = useWorkspacesAPI();
const [visible, setVisible] = useState(false);
const [seenActivities, setSeenActivities] = useLocalStorage("seen_activities", [])
const [eventModalInfo, setShowEventInfo] = useState()

const activities = useMemo(() => appActivityCache.reduce((acc, cur) => {
const aid = cur.data.appId
const sid = cur.data.systemId
if (!acc[sid]) acc[sid] = []
acc[sid].push(cur)
// If an event exists for an app that isn't in the available apps
// list anymore, then we shouldn't include that event.
if (appSpecs.hasOwnProperty(aid)) {
if (!acc[sid]) acc[sid] = []
acc[sid].push(cur)
}
return acc
}, {}), [appActivityCache])
}, {}), [appActivityCache, appSpecs])
const notificationCount = useMemo(() => {
return appActivityCache.filter((event) => !seenActivities.includes(event.uid)).length
}, [appActivityCache, seenActivities])
Expand Down

0 comments on commit faebc23

Please sign in to comment.