state: add isReceiptBefore
This commit is contained in:
parent
5f8cd976e6
commit
2ac7be6218
2 changed files with 18 additions and 8 deletions
13
state.js
13
state.js
|
@ -95,6 +95,19 @@ export function receiptFromMessage(msg) {
|
|||
return { time: msg.tags.time };
|
||||
}
|
||||
|
||||
export function isReceiptBefore(a, b) {
|
||||
if (!b) {
|
||||
return false;
|
||||
}
|
||||
if (!a) {
|
||||
return true;
|
||||
}
|
||||
if (!a.time || !b.time) {
|
||||
throw new Error("Missing receipt time");
|
||||
}
|
||||
return a.time <= b.time;
|
||||
}
|
||||
|
||||
export function isMessageBeforeReceipt(msg, receipt) {
|
||||
if (!receipt) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue