Update
This commit is contained in:
1 parent
cfb96f03c0
commit
b7f7d7e793
3 files changed
+58
-6
No files matched your search
@@ -298,12 +298,38 @@ function comparablePreviewValue(value: unknown) {
|
||||
return value ?? null;
|
||||
}
|
||||
|
||||
function cachedValueChanged(left: unknown, right: unknown) {
|
||||
return JSON.stringify(comparablePreviewValue(left)) !== JSON.stringify(comparablePreviewValue(right));
|
||||
function comparablePreviewIdValue(value: unknown) {
|
||||
const comparable = comparablePreviewValue(value);
|
||||
|
||||
if (typeof comparable === "number" && Number.isInteger(comparable)) {
|
||||
return String(comparable);
|
||||
}
|
||||
|
||||
if (typeof comparable === "bigint") {
|
||||
return comparable.toString();
|
||||
}
|
||||
|
||||
if (typeof comparable === "string" && /^\d+$/.test(comparable.trim())) {
|
||||
return comparable.trim().replace(/^0+(?=\d)/, "");
|
||||
}
|
||||
|
||||
return comparable;
|
||||
}
|
||||
|
||||
function comparablePreviewValueForField(field: string, value: unknown) {
|
||||
if (field === "Organisation") {
|
||||
return comparablePreviewIdValue(value);
|
||||
}
|
||||
|
||||
return comparablePreviewValue(value);
|
||||
}
|
||||
|
||||
function cachedValueChanged(field: string, left: unknown, right: unknown) {
|
||||
return JSON.stringify(comparablePreviewValueForField(field, left)) !== JSON.stringify(comparablePreviewValueForField(field, right));
|
||||
}
|
||||
|
||||
function addCachedChange(changes: ZammadSyncChange[], field: string, from: unknown, to: unknown) {
|
||||
if (cachedValueChanged(from, to)) {
|
||||
if (cachedValueChanged(field, from, to)) {
|
||||
changes.push({ field, from: comparablePreviewValue(from), to: comparablePreviewValue(to) });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user