mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-03 03:36:23 -04:00
pagination
This commit is contained in:
parent
5473bd2ee4
commit
2c38fc6489
22 changed files with 1071 additions and 545 deletions
|
@ -39,11 +39,13 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||
}
|
||||
final bLookup = await _spine.lookupPosition(bPos);
|
||||
if (bLookup == null) {
|
||||
await aLookup.close();
|
||||
throw StateError("can't lookup position b in swap of dht log");
|
||||
}
|
||||
|
||||
// Swap items in the segments
|
||||
if (aLookup.shortArray == bLookup.shortArray) {
|
||||
await bLookup.close();
|
||||
await aLookup.scope((sa) => sa.operateWriteEventual((aWrite) async {
|
||||
await aWrite.swap(aLookup.pos, bLookup.pos);
|
||||
return true;
|
||||
|
@ -76,7 +78,9 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||
}
|
||||
|
||||
// Write item to the segment
|
||||
return lookup.scope((sa) => sa.operateWrite((write) async {
|
||||
return lookup.scope((sa) async {
|
||||
try {
|
||||
return sa.operateWrite((write) async {
|
||||
// If this a new segment, then clear it in case we have wrapped around
|
||||
if (lookup.pos == 0) {
|
||||
await write.clear();
|
||||
|
@ -85,7 +89,11 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||
throw StateError('appending should be at the end');
|
||||
}
|
||||
return write.tryAdd(value);
|
||||
}));
|
||||
});
|
||||
} on DHTExceptionTryAgain {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -110,7 +118,9 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||
final sublistValues = values.sublist(valueIdx, valueIdx + sacount);
|
||||
|
||||
dws.add(() async {
|
||||
final ok = await lookup.scope((sa) => sa.operateWrite((write) async {
|
||||
final ok = await lookup.scope((sa) async {
|
||||
try {
|
||||
return sa.operateWrite((write) async {
|
||||
// If this a new segment, then clear it in
|
||||
// case we have wrapped around
|
||||
if (lookup.pos == 0) {
|
||||
|
@ -120,7 +130,11 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||
throw StateError('appending should be at the end');
|
||||
}
|
||||
return write.tryAddAll(sublistValues);
|
||||
}));
|
||||
});
|
||||
} on DHTExceptionTryAgain {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!ok) {
|
||||
success = false;
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ class TableDBArrayProtobufCubit<T extends GeneratedMessage>
|
|||
final elements = avElements.asData!.value;
|
||||
emit(AsyncValue.data(TableDBArrayProtobufStateData(
|
||||
windowElements: elements,
|
||||
length: _array.length,
|
||||
windowTail: _tail,
|
||||
windowCount: _count,
|
||||
follow: _follow)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue