Reduce Android realtime heartbeat noise
This commit is contained in:
@@ -7648,6 +7648,7 @@ export async function upsertDeviceHeartbeat(payload: {
|
||||
}>;
|
||||
}) {
|
||||
const result = await mutateState((state) => {
|
||||
let conversationRefreshRequired = false;
|
||||
const projectUnderstandingSyncRequests: Array<{
|
||||
projectId: string;
|
||||
observedActivityAt: string;
|
||||
@@ -7761,6 +7762,7 @@ export async function upsertDeviceHeartbeat(payload: {
|
||||
} else if (!existing.deviceIds.includes(payload.deviceId)) {
|
||||
existing.deviceIds.push(payload.deviceId);
|
||||
existing.isGroup = existing.deviceIds.length > 1;
|
||||
conversationRefreshRequired = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7896,6 +7898,7 @@ export async function upsertDeviceHeartbeat(payload: {
|
||||
pruneMissingCandidates: true,
|
||||
});
|
||||
draft = applied.draft;
|
||||
conversationRefreshRequired = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7905,13 +7908,16 @@ export async function upsertDeviceHeartbeat(payload: {
|
||||
pairingStatus: claimedEnrollment?.status,
|
||||
importDraft: draft,
|
||||
projectUnderstandingSyncRequests,
|
||||
conversationRefreshRequired,
|
||||
};
|
||||
});
|
||||
for (const request of result.projectUnderstandingSyncRequests ?? []) {
|
||||
await queueProjectUnderstandingSyncTask(request);
|
||||
}
|
||||
publishBossEvent("devices.updated", { deviceId: payload.deviceId });
|
||||
publishBossEvent("conversation.updated", { deviceId: payload.deviceId });
|
||||
if (result.conversationRefreshRequired) {
|
||||
publishBossEvent("conversation.updated", { deviceId: payload.deviceId, note: "device_import.updated" });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -7994,6 +8000,13 @@ function shouldAutoSyncHeartbeatCandidates(input: {
|
||||
if (!input.wasExistingDevice) return false;
|
||||
if (input.device.source !== "production") return false;
|
||||
if (!input.draft || input.draft.candidates.length === 0) return false;
|
||||
if (
|
||||
input.draft.status === "applied" &&
|
||||
input.draft.resolutionId &&
|
||||
sameStringSet(input.draft.selectedCandidateIds, resolveAutoSyncCandidateIds(input.draft))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
input.claimedEnrollment?.enrollmentId &&
|
||||
input.draft.enrollmentId === input.claimedEnrollment.enrollmentId
|
||||
|
||||
Reference in New Issue
Block a user