mirror of https://codeberg.org/pzp/pzp-set.git
refactor secret-stack plugin init function
This commit is contained in:
parent
6980d41207
commit
b0afc57ed6
33
lib/index.js
33
lib/index.js
|
@ -73,15 +73,11 @@ function assert(check, message) {
|
|||
if (!check) throw new Error(message)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'set',
|
||||
manifest: {},
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {{ db: PPPPPDB | null, close: ClosableHook }} peer
|
||||
* @param {any} config
|
||||
*/
|
||||
init(peer, config) {
|
||||
function initSet(peer, config) {
|
||||
assertDBPlugin(peer)
|
||||
|
||||
//#region state
|
||||
|
@ -363,9 +359,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
const data = { add: [value], del: [], supersedes }
|
||||
peer.db.feed.publish(
|
||||
{ account: accountID, domain, data },
|
||||
(err, rec) => {
|
||||
peer.db.feed.publish({ account: accountID, domain, data }, (err, rec) => {
|
||||
// prettier-ignore
|
||||
if (err) return cb(new Error(`Failed to create msg when adding to Set (${id}/${subdomain})`, { cause: err }))
|
||||
for (const [msgID, item] of toDeleteFromItemRoots) {
|
||||
|
@ -373,8 +367,7 @@ module.exports = {
|
|||
}
|
||||
// @ts-ignore
|
||||
cb(null, true)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -406,15 +399,12 @@ module.exports = {
|
|||
}
|
||||
|
||||
const data = { add: [], del: [value], supersedes }
|
||||
peer.db.feed.publish(
|
||||
{ account: accountID, domain, data },
|
||||
(err, rec) => {
|
||||
peer.db.feed.publish({ account: accountID, domain, data }, (err, rec) => {
|
||||
// prettier-ignore
|
||||
if (err) return cb(new Error(`Failed to create msg when deleting from Set (${id}/${subdomain})`, { cause: err }))
|
||||
// @ts-ignore
|
||||
cb(null, true)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -473,15 +463,12 @@ module.exports = {
|
|||
}
|
||||
|
||||
const data = { add: [...currentSet], del: [], supersedes }
|
||||
peer.db.feed.publish(
|
||||
{ account: accountID, domain, data },
|
||||
(err, rec) => {
|
||||
peer.db.feed.publish({ account: accountID, domain, data }, (err, rec) => {
|
||||
// prettier-ignore
|
||||
if (err) return cb(new Error(`Failed to create msg when squeezing Set (${id}/${subdomain})`, { cause: err }))
|
||||
// @ts-ignore
|
||||
cb(null, true)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
//#endregion
|
||||
|
@ -497,5 +484,7 @@ module.exports = {
|
|||
|
||||
_squeezePotential,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
exports.name = 'set'
|
||||
exports.init = initSet
|
||||
|
|
Loading…
Reference in New Issue