mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 23:40:57 +01:00
ircd:Ⓜ️:dbs: Factor in the event_idx for a more stable messages sort.
This commit is contained in:
parent
246e20d624
commit
2557834a96
1 changed files with 13 additions and 6 deletions
|
@ -563,21 +563,28 @@ ircd::m::dbs::desc::events__room_events__cmp
|
||||||
b.substr(sizes[1]),
|
b.substr(sizes[1]),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// These conditions are matched on some queries when the user only
|
||||||
|
// supplies a room id.
|
||||||
|
|
||||||
if(empty(post[0]))
|
if(empty(post[0]))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(empty(post[1]))
|
if(empty(post[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Now want just the depth...
|
// Distill out the depth and event_idx integers
|
||||||
const uint64_t depth[2]
|
const std::pair<uint64_t, event::idx> pair[2]
|
||||||
{
|
{
|
||||||
room_events_key(post[0]).first,
|
room_events_key(post[0]),
|
||||||
room_events_key(post[1]).first,
|
room_events_key(post[1])
|
||||||
};
|
};
|
||||||
|
|
||||||
// Highest to lowest sort so highest is first
|
// When two events are at the same depth sort by index (the sequence
|
||||||
return depth[1] < depth[0];
|
// number given as they were admitted into the system) otherwise
|
||||||
|
// sort by depth. Note this is a reverse order comparison.
|
||||||
|
return std::get<0>(pair[1]) != std::get<0>(pair[0])?
|
||||||
|
std::get<0>(pair[1]) < std::get<0>(pair[0]):
|
||||||
|
std::get<1>(pair[1]) < std::get<1>(pair[0]);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue