Make sure deletes are by the same author

This commit is contained in:
Jon Staab
2026-03-23 10:03:52 -07:00
parent 1a160ec485
commit a21448c0df
3 changed files with 82 additions and 23 deletions
+18 -8
View File
@@ -1150,9 +1150,9 @@ export const randomId = (): string => Math.random().toString().slice(2)
*/
export const sleep = (t: number) => new Promise(resolve => setTimeout(resolve, t))
export type PollOptions = {
export type PollOptions<T> = {
signal: AbortSignal
condition: () => boolean
condition: () => T
interval?: number
}
@@ -1161,17 +1161,21 @@ export type PollOptions = {
* @param options - PollOptions
* @returns void Promise
*/
export const poll = ({interval = 300, condition, signal}: PollOptions) =>
new Promise<void>(resolve => {
export const poll = <T>({interval = 300, condition, signal}: PollOptions<T>) =>
new Promise<T | void>(resolve => {
const int = setInterval(() => {
if (condition()) {
resolve()
const value = condition()
if (value !== undefined) {
resolve(value)
clearInterval(int)
}
}, interval)
if (condition()) {
resolve()
const value = condition()
if (value !== undefined) {
resolve(value)
clearInterval(int)
}
@@ -1610,6 +1614,12 @@ export const prop =
(x: Record<string, unknown>) =>
x[k] as T
/** Returns a function that checks whether the object's property value is in a list */
export const propIn =
<T>(k: string, xs: T[]) =>
(x: Record<string, unknown>) =>
xs.includes(x[k] as T)
/** Returns a function that adds/updates a property on object */
export const assoc =
<K extends string, T>(k: K, v: T) =>