use once
This commit is contained in:
parent
0df700000b
commit
c2050c30fb
1 changed files with 14 additions and 5 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
/* eslint-disable init-declarations */
|
/* eslint-disable init-declarations */
|
||||||
const logger = require('winston')
|
const logger = require('winston')
|
||||||
const { Constants } = require('shock-common')
|
const { Constants, Utils: CommonUtils } = require('shock-common')
|
||||||
|
|
||||||
const Key = require('../key')
|
const Key = require('../key')
|
||||||
|
|
||||||
|
|
@ -213,10 +213,19 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
||||||
const pubToEpub = async pub => {
|
const pubToEpub = async pub => {
|
||||||
try {
|
try {
|
||||||
const epub = await tryAndWait(async gun => {
|
const epub = await tryAndWait(async gun => {
|
||||||
const _epub = await gun
|
const _epub = await CommonUtils.makePromise(res => {
|
||||||
.user(pub)
|
gun
|
||||||
.get('epub')
|
.user(pub)
|
||||||
.then()
|
.get('epub')
|
||||||
|
.once(
|
||||||
|
data => {
|
||||||
|
res(data)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
wait: 1000
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
if (typeof _epub !== 'string') {
|
if (typeof _epub !== 'string') {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue