Live Location Sharing - left panel warning with error (#8201)

* add error style to left panel beacon warning

Signed-off-by: Kerry Archibald <kerrya@element.io>

* test

Signed-off-by: Kerry Archibald <kerrya@element.io>

* add beacon sort util

* link to latest beacon room from left panel warning

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-03-31 13:51:44 +02:00 committed by GitHub
parent 1175226bcb
commit 4922e19b5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 289 additions and 24 deletions

View file

@ -16,7 +16,11 @@ limitations under the License.
import { Beacon } from "matrix-js-sdk/src/matrix";
import { msUntilExpiry, sortBeaconsByLatestExpiry } from "../../../src/utils/beacon";
import {
msUntilExpiry,
sortBeaconsByLatestExpiry,
sortBeaconsByLatestCreation,
} from "../../../src/utils/beacon";
import { makeBeaconInfoEvent } from "../../test-utils";
describe('beacon utils', () => {
@ -80,4 +84,35 @@ describe('beacon utils', () => {
]);
});
});
describe('sortBeaconsByLatestCreation()', () => {
const roomId = '!room:server';
const aliceId = '@alive:server';
// 12h old, 12h left
const beacon1 = new Beacon(makeBeaconInfoEvent(aliceId,
roomId,
{ timeout: HOUR_MS * 24, timestamp: now - 12 * HOUR_MS },
'$1',
));
// 10h left
const beacon2 = new Beacon(makeBeaconInfoEvent(aliceId,
roomId,
{ timeout: HOUR_MS * 10, timestamp: now },
'$2',
));
// 1ms left
const beacon3 = new Beacon(makeBeaconInfoEvent(aliceId,
roomId,
{ timeout: HOUR_MS + 1, timestamp: now - HOUR_MS },
'$3',
));
it('sorts beacons by descending creation time', () => {
expect([beacon1, beacon2, beacon3].sort(sortBeaconsByLatestCreation)).toEqual([
beacon2, beacon3, beacon1,
]);
});
});
});