mirror of https://codeberg.org/pzp/pzp-db.git
refactor: use initializeFeed() inside create()
This commit is contained in:
parent
9dd5f92ce8
commit
d39ee6b017
12
lib/index.js
12
lib/index.js
|
@ -237,16 +237,9 @@ exports.init = function initDB(peer, config) {
|
|||
if (!opts.content) return cb(new Error('create() requires a `content`'))
|
||||
if (!opts.type) return cb(new Error('create() requires a `type`'))
|
||||
|
||||
const feedRootHash = getFeedRoot(FeedV1.stripAuthor(keys.id), opts.type)
|
||||
if (!feedRootHash) {
|
||||
const feedRoot = FeedV1.createRoot(keys, opts.type)
|
||||
add(feedRoot, FeedV1.getMsgHash(feedRoot), (err) => {
|
||||
initializeFeed(opts, (err, feedRootHash) => {
|
||||
// prettier-ignore
|
||||
if (err) return cb(new Error('create() failed to create root', {cause: err}));
|
||||
create(opts, cb)
|
||||
})
|
||||
return
|
||||
}
|
||||
if (err) return cb(new Error('create() failed to initialize feed', { cause: err }));
|
||||
|
||||
// Fill-in tangle opts:
|
||||
const tangleTemplates = opts.tangles ?? []
|
||||
|
@ -290,6 +283,7 @@ exports.init = function initDB(peer, config) {
|
|||
onRecordAdded.set(rec)
|
||||
cb(null, rec)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getFeedRoot(authorId, findType) {
|
||||
|
|
Loading…
Reference in New Issue