Skip to content

Commit

Permalink
Hook some more compat things
Browse files Browse the repository at this point in the history
  • Loading branch information
Powersource committed Nov 21, 2023
1 parent 45c875f commit c344520
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 8 additions & 7 deletions compat/ebt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@
// SPDX-License-Identifier: LGPL-3.0-only

const pull = require('pull-stream')
const Hookable = require('hoox')
const EBTIndex = require('../indexes/ebt')
const { onceWhen } = require('../utils')

exports.init = function (sbot, config) {
sbot.db.registerIndex(EBTIndex)
if (!sbot.post) sbot.post = sbot.db.post
sbot.getAtSequence = (key, cb) => {
sbot.getAtSequence = Hookable((key, cb) => {
sbot.db.onDrain('ebt', () => {
sbot.db.getIndex('ebt').getMessageFromAuthorSequence(key, cb)
})
}
sbot.getAtSequenceNativeMsg = (key, feedFormat, cb) => {
})
sbot.getAtSequenceNativeMsg = Hookable((key, feedFormat, cb) => {
sbot.db.onDrain('ebt', () => {
sbot.db
.getIndex('ebt')
.getNativeMsgFromAuthorSequence(key, feedFormat, cb)
})
}
sbot.add = sbot.db.add
sbot.getVectorClock = function getVectorClock(cb) {
})
sbot.add = Hookable(sbot.db.add)
sbot.getVectorClock = Hookable(function getVectorClock(cb) {
onceWhen(
sbot.db2migrate && sbot.db2migrate.synchronized,
(isSynced) => isSynced === true,
Expand All @@ -45,5 +46,5 @@ exports.init = function (sbot, config) {
})
}
)
}
})
}
5 changes: 3 additions & 2 deletions compat/feedstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
//
// SPDX-License-Identifier: LGPL-3.0-only

const Hookable = require('hoox')
const { onceWhen } = require('../utils')

exports.init = function (sbot, config) {
sbot.getFeedState = function (feedId, cb) {
sbot.getFeedState = Hookable(function (feedId, cb) {
onceWhen(
sbot.db.stateFeedsReady,
(ready) => ready === true,
Expand All @@ -21,5 +22,5 @@ exports.init = function (sbot, config) {
})
}
)
}
})
}

0 comments on commit c344520

Please sign in to comment.