MCPcopy Create free account
hub / github.com/dfinity/orbit / run

Method run

apps/wallet/src/workers/notifications.worker.ts:119–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117 }
118
119 private async run(): Promise<void> {
120 if (!this.enabled || this.loading) {
121 return;
122 }
123
124 try {
125 this.loading = true;
126 await icAgent.loadIdentity();
127
128 const notifications = await this.stationService.listUnreadNotifications(
129 this.lastNotificationDate ?? undefined,
130 this.lastNotificationId ?? undefined,
131 );
132 const lastNotification = notifications?.[0];
133 this.lastNotificationId = lastNotification?.id ?? null;
134 if (lastNotification) {
135 this.lastNotificationDate = new Date(lastNotification.created_at);
136 }
137
138 postMessage({
139 type: 'notifications',
140 data: {
141 notifications,
142 },
143 } as NotificationsWorkerResponseMessage);
144 } catch (err) {
145 logger.error(`Failed to fetch notifications`, { err });
146
147 postMessage({
148 type: 'error',
149 data: {
150 code: 'ERR_FETCH_NOTIFICATIONS',
151 msg: `Failed to fetch notifications: ${err}`,
152 },
153 } as NotificationsWorkerResponseMessage);
154 } finally {
155 this.loading = false;
156 }
157 }
158}
159
160NotificationsWorkerImpl.register();

Callers 1

startMethod · 0.95

Calls 2

loadIdentityMethod · 0.80

Tested by

no test coverage detected