@go-avro/avro-js 0.0.113 → 0.0.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/QueryClient.js +39 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -365,6 +365,9 @@ const SOCKET_EVENT_CONFIG = {
|
|
|
365
365
|
invalidateKeys: [['companies'], ['/company/list']],
|
|
366
366
|
},
|
|
367
367
|
// ── Location ──
|
|
368
|
+
// Handled surgically in setupSocketInvalidation (patches
|
|
369
|
+
// `current_location` / `last_location` in place); these keys are
|
|
370
|
+
// only the fallback for malformed payloads.
|
|
368
371
|
location_update: { invalidateKeys: [['teams']] },
|
|
369
372
|
// ── Prepayments ──
|
|
370
373
|
update_prepayments: { invalidateKeys: [['prepayments']] },
|
|
@@ -531,13 +534,46 @@ export class AvroQueryClient {
|
|
|
531
534
|
};
|
|
532
535
|
queryClient.setQueriesData({ queryKey: ['users', 'company'] }, (old) => Array.isArray(old) ? patchMembers(old) : old);
|
|
533
536
|
};
|
|
537
|
+
const patchTeamLocation = (data) => {
|
|
538
|
+
const teamId = data.team_id;
|
|
539
|
+
if (!teamId || typeof teamId !== 'string')
|
|
540
|
+
return;
|
|
541
|
+
const patchTeams = (teams) => {
|
|
542
|
+
let changed = false;
|
|
543
|
+
const next = teams.map((t) => {
|
|
544
|
+
if (t?.id !== teamId)
|
|
545
|
+
return t;
|
|
546
|
+
changed = true;
|
|
547
|
+
return { ...t, current_location: data };
|
|
548
|
+
});
|
|
549
|
+
return changed ? next : teams;
|
|
550
|
+
};
|
|
551
|
+
queryClient.setQueriesData({ queryKey: ['teams'] }, (old) => {
|
|
552
|
+
if (Array.isArray(old))
|
|
553
|
+
return patchTeams(old);
|
|
554
|
+
if (old?.pages) {
|
|
555
|
+
return {
|
|
556
|
+
...old,
|
|
557
|
+
pages: old.pages.map((page) => Array.isArray(page) ? patchTeams(page) : page),
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (old?.id === teamId)
|
|
561
|
+
return { ...old, current_location: data };
|
|
562
|
+
return old;
|
|
563
|
+
});
|
|
564
|
+
};
|
|
534
565
|
for (const [event, config] of Object.entries(SOCKET_EVENT_CONFIG)) {
|
|
535
566
|
if (event === 'location_update' && isBulkEvent(config)) {
|
|
536
567
|
const handler = (data) => {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
568
|
+
if (!data || typeof data.latitude !== 'number') {
|
|
569
|
+
for (const key of config.invalidateKeys) {
|
|
570
|
+
queryClient.invalidateQueries({ queryKey: key });
|
|
571
|
+
}
|
|
540
572
|
}
|
|
573
|
+
else {
|
|
574
|
+
patchTeamLocation(data);
|
|
575
|
+
}
|
|
576
|
+
patchMemberLocation(data);
|
|
541
577
|
};
|
|
542
578
|
this.socket.on(event, handler);
|
|
543
579
|
handlers.push({ event, handler });
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "0.0.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "0.0.114";
|
package/dist/version.js
CHANGED