You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Live location sharing - Aggregate beacon locations on beacons (#2268)
* add timestamp sorting util Signed-off-by: Kerry Archibald <kerrya@element.io> * basic wiring Signed-off-by: Kerry Archibald <kerrya@element.io> * quick handle for redacted beacons Signed-off-by: Kerry Archibald <kerrya@element.io> * remove fdescribe Signed-off-by: Kerry Archibald <kerrya@element.io> * test adding locations Signed-off-by: Kerry Archibald <kerrya@element.io> * tidy comments Signed-off-by: Kerry Archibald <kerrya@element.io> * test client Signed-off-by: Kerry Archibald <kerrya@element.io> * fix monitorLiveness for update Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
14
src/utils.ts
14
src/utils.ts
@@ -24,6 +24,8 @@ import unhomoglyph from "unhomoglyph";
|
||||
import promiseRetry from "p-retry";
|
||||
|
||||
import type NodeCrypto from "crypto";
|
||||
import { MatrixEvent } from ".";
|
||||
import { M_TIMESTAMP } from "./@types/location";
|
||||
|
||||
/**
|
||||
* Encode a dictionary of query parameters.
|
||||
@@ -708,3 +710,15 @@ export function recursivelyAssign(target: Object, source: Object, ignoreNullish
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function getContentTimestampWithFallback(event: MatrixEvent): number {
|
||||
return M_TIMESTAMP.findIn<number>(event.getContent()) ?? -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort events by their content m.ts property
|
||||
* Latest timestamp first
|
||||
*/
|
||||
export function sortEventsByLatestContentTimestamp(left: MatrixEvent, right: MatrixEvent): number {
|
||||
return getContentTimestampWithFallback(right) - getContentTimestampWithFallback(left);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user