2019-03-04 01:21:22 +00:00
|
|
|
import { toReversePaddedBigInt, zeroPad } from '../_utils/statusIdSorting'
|
2018-03-11 04:24:07 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// timelines
|
|
|
|
//
|
|
|
|
|
|
|
|
export function createTimelineId (timeline, id) {
|
|
|
|
// reverse chronological order, prefixed by timeline
|
|
|
|
return timeline + '\u0000' + toReversePaddedBigInt(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createTimelineKeyRange (timeline, maxId) {
|
|
|
|
let negBigInt = maxId && toReversePaddedBigInt(maxId)
|
|
|
|
let start = negBigInt ? (timeline + '\u0000' + negBigInt) : (timeline + '\u0000')
|
|
|
|
let end = timeline + '\u0000\uffff'
|
|
|
|
return IDBKeyRange.bound(start, end, true, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// threads
|
|
|
|
//
|
|
|
|
|
|
|
|
export function createThreadId (statusId, i) {
|
|
|
|
return statusId + '\u0000' + zeroPad(i, 5)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createThreadKeyRange (statusId) {
|
|
|
|
return IDBKeyRange.bound(
|
|
|
|
statusId + '\u0000',
|
|
|
|
statusId + '\u0000\uffff'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// pinned statues
|
|
|
|
//
|
|
|
|
|
|
|
|
export function createPinnedStatusId (accountId, i) {
|
|
|
|
return accountId + '\u0000' + zeroPad(i, 3)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createPinnedStatusKeyRange (accountId) {
|
|
|
|
return IDBKeyRange.bound(
|
|
|
|
accountId + '\u0000',
|
|
|
|
accountId + '\u0000\uffff'
|
|
|
|
)
|
|
|
|
}
|
2018-03-25 01:04:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// accounts
|
|
|
|
//
|
|
|
|
|
|
|
|
export function createAccountUsernamePrefixKeyRange (accountUsernamePrefix) {
|
|
|
|
return IDBKeyRange.bound(
|
|
|
|
accountUsernamePrefix,
|
|
|
|
accountUsernamePrefix + '\uffff'
|
|
|
|
)
|
|
|
|
}
|