73abba06cf
* WIP infinite load helper * finished automations pagination * runs pagination working * fn pagination * minor cleanup * subscription cache mutation fixes * filtered cache update fix * minor changes
32 lines
765 B
TypeScript
32 lines
765 B
TypeScript
import { base64Decode, base64Encode } from '@/modules/shared/helpers/cryptoHelper'
|
|
import dayjs, { Dayjs } from 'dayjs'
|
|
|
|
/**
|
|
* Encode cursor to turn it into an opaque & obfuscated value
|
|
*/
|
|
export function encodeCursor(value: string): string {
|
|
return base64Encode(value)
|
|
}
|
|
|
|
/**
|
|
* Decode obfuscated cursor value
|
|
*/
|
|
export function decodeCursor(value: string): string {
|
|
return base64Decode(value)
|
|
}
|
|
|
|
export function decodeIsoDateCursor(value: string): string | null {
|
|
const decoded = decodeCursor(value)
|
|
if (!decoded) return null
|
|
|
|
const date = dayjs(decoded)
|
|
if (!date.isValid()) return null
|
|
|
|
return date.toISOString()
|
|
}
|
|
|
|
export function encodeIsoDateCursor(date: Date | Dayjs): string {
|
|
const str = date.toISOString()
|
|
return encodeCursor(str)
|
|
}
|