-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(store): Refactor north arrow to use the store and remove api…
… from footer element Closes #1329
- Loading branch information
Johann Levesque
committed
Oct 6, 2023
1 parent
3434747
commit fe12955
Showing
33 changed files
with
657 additions
and
709 deletions.
There are no files selected for viewing
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,15 +1,20 @@ | ||
import { GeoViewStoreType } from '@/core/stores/geoview-store'; | ||
import { AppBarEventProcessor } from './appBar-event-process'; | ||
import { MapEventProcessor } from './map-event-process'; | ||
import { AppBarEventProcessor } from '@/api/eventProcessors/appBar-event-process'; | ||
import { MapEventProcessor } from '@/api/eventProcessors/map-event-process'; | ||
import { NotificationEventProcessor } from '@/api/eventProcessors/notification-event-process'; | ||
|
||
const mapEventProcessor = new MapEventProcessor(); | ||
const appBarEventProcessor = new AppBarEventProcessor(); | ||
const mapEventProcessor = new MapEventProcessor(); | ||
const notificationEventProcessor = new NotificationEventProcessor(); | ||
|
||
export function initializeEventProcessors(store: GeoViewStoreType) { | ||
mapEventProcessor.onInitialize(store); | ||
appBarEventProcessor.onInitialize(store); | ||
notificationEventProcessor.onInitialize(store); | ||
} | ||
|
||
export function destroyEventProcessors() { | ||
mapEventProcessor.onDestroy(); | ||
appBarEventProcessor.onDestroy(); | ||
notificationEventProcessor.onDestroy(); | ||
} |
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
33 changes: 33 additions & 0 deletions
33
packages/geoview-core/src/api/eventProcessors/notification-event-process.ts
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,33 @@ | ||
import { GeoViewStoreType } from '@/core/stores/geoview-store'; | ||
import { AbstractEventProcessor } from './abstract-event-processor'; | ||
import { PayloadBaseClass, payloadIsANotification } from '@/api/events/payloads'; | ||
import { EVENT_NAMES } from '@/api/events/event-types'; | ||
import { api, generateId } from '@/app'; | ||
|
||
export class NotificationEventProcessor extends AbstractEventProcessor { | ||
onInitialize(store: GeoViewStoreType) { | ||
const { mapId } = store.getState(); | ||
|
||
// TODO: add a destroy events on store/map destroy | ||
// when the add notification is triggered, add it to the strore notifications array | ||
api.event.on( | ||
EVENT_NAMES.NOTIFICATIONS.NOTIFICATION_ADD, | ||
(payload: PayloadBaseClass) => { | ||
if (payloadIsANotification(payload)) { | ||
store.setState((state) => ({ | ||
notificationState: { | ||
notifications: [ | ||
...state.notificationState.notifications, | ||
{ key: generateId(), notificationType: payload.notificationType, message: payload.message }, | ||
], | ||
}, | ||
})); | ||
} | ||
}, | ||
mapId | ||
); | ||
|
||
// add to arr of subscriptions so it can be destroyed later | ||
this.subscriptionArr.push(); | ||
} | ||
} |
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
189 changes: 0 additions & 189 deletions
189
packages/geoview-core/src/core/components/app-bar/buttons/notifications.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.