mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(site): resolve all Array.prototype.toSorted and Array.prototype.sort bugs (#17307)
Closes https://github.com/coder/coder/issues/16759 ## Changes made - Replaced all instances of `Array.prototype.toSorted` with `Array.prototype.sort` to provide better support for older browsers - Updated all `Array.prototype.sort` calls where necessary to remove risks of mutation render bugs - Refactored some code (moved things around, added comments) to make it more clear that certain `.sort` calls are harmless and don't have any risks
This commit is contained in:
@@ -13,9 +13,9 @@ export const mergeTimeRanges = (ranges: TimeRange[]): TimeRange => {
|
||||
.sort((a, b) => a.startedAt.getTime() - b.startedAt.getTime());
|
||||
const start = sortedDurations[0].startedAt;
|
||||
|
||||
const sortedEndDurations = ranges
|
||||
.slice()
|
||||
.sort((a, b) => a.endedAt.getTime() - b.endedAt.getTime());
|
||||
const sortedEndDurations = [...ranges].sort(
|
||||
(a, b) => a.endedAt.getTime() - b.endedAt.getTime(),
|
||||
);
|
||||
const end = sortedEndDurations[sortedEndDurations.length - 1].endedAt;
|
||||
return { startedAt: start, endedAt: end };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user