diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 4b90b04e..f620cfc6 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,9 @@ # Release Notes +## v1.16.3 - 2020-02-13 +* fix: getIPFS called same time or from different closures in browser +* fix: ghost chat member list, with no auth opens + ## v1.16.2 - 2020-02-05 * chore: update ipfs & orbitdb * fix: Verify legacy muport DID properly diff --git a/package.json b/package.json index ec80c1ce..5d1b5532 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "3box", - "version": "1.16.2", + "version": "1.16.3", "description": "Interact with user data", "main": "lib/3box.js", "directories": { diff --git a/src/3box.js b/src/3box.js index 2132d775..29a6d0f4 100644 --- a/src/3box.js +++ b/src/3box.js @@ -21,7 +21,7 @@ const PINNING_NODE = config.pinning_node const ADDRESS_SERVER_URL = config.address_server_url const IPFS_OPTIONS = config.ipfs_options -let globalIPFS // , ipfsProxy, cacheProxy, iframeLoadedPromise +let globalIPFS, globalIPFSPromise // , ipfsProxy, cacheProxy, iframeLoadedPromise /* if (typeof window !== 'undefined' && typeof document !== 'undefined') { @@ -509,8 +509,20 @@ class Box extends BoxApi { * @return {IPFS} the ipfs instance */ static async getIPFS (opts = {}) { - const ipfs = globalIPFS || await initIPFS(opts.ipfs, opts.iframeStore, opts.ipfsOptions) - globalIPFS = ipfs + if (typeof window !== 'undefined') { + globalIPFS = window.globalIPFS + globalIPFSPromise = window.globalIPFSPromise + } + + if (!globalIPFS && !globalIPFSPromise) { + globalIPFSPromise = initIPFS(opts.ipfs, opts.iframeStore, opts.ipfsOptions) + } + if (typeof window !== 'undefined') window.globalIPFSPromise = globalIPFSPromise + + if (!globalIPFS) globalIPFS = await globalIPFSPromise + if (typeof window !== 'undefined') window.globalIPFS = globalIPFS + + const ipfs = globalIPFS const pinningNode = opts.pinningNode || PINNING_NODE ipfs.swarm.connect(pinningNode, () => {}) return ipfs diff --git a/src/ghost.js b/src/ghost.js index 71de9fd7..38032f0c 100644 --- a/src/ghost.js +++ b/src/ghost.js @@ -73,8 +73,8 @@ class GhostThread extends EventEmitter { this._3id = threeId // announce to other peers that we are online this.listMembers().then(members => { - members.map(({ id }) => { - this._announce(this._threeIdToPeerId(id)) + this._room.getPeers().map(id => { + this._announce(id) }) }) } @@ -228,7 +228,7 @@ class GhostThread extends EventEmitter { */ async _userJoined (did, peerID) { const members = await this.listMembers() - if (!members.includes(did) && (this._3id && this._3id.DID !== did)) { + if (!members.includes(did) && (!this._3id || this._3id.DID !== did)) { this._members[did] = peerID this._members[peerID] = did this.emit('user-joined', 'joined', did, peerID)