Skip to content

Commit 2da2fb2

Browse files
authored
Quick refactor (#7)
* refactor a couple things for less code complexity * fixed syntax error * remove unused else
1 parent cd26d64 commit 2da2fb2

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/ipfs/getIpfs.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const loadWindowIpfs = async permissions => {
2828
ipfs = await window.ipfs.enable({
2929
commands: permissions
3030
});
31-
} else {
3231
}
3332
const isWorking = await ipfsIsWorking(ipfs);
3433
if (isWorking) {
@@ -58,21 +57,21 @@ export const loadJsIpfs = async () => {
5857
});
5958
};
6059

61-
const getIpfs = (permissions = DEFAULT_PERMISSIONS) => {
62-
// if already instantiated
63-
if (ipfsInstance) {
64-
return ipfsInstance;
65-
}
60+
const getIpfs = async (permissions = DEFAULT_PERMISSIONS) => {
61+
// if already instantiated
62+
if (ipfsInstance) {
63+
return ipfsInstance;
64+
}
6665

67-
ipfsInstance = await loadWindowIpfs(permissions)
68-
if(ipfsInstance){
69-
console.log("window.ipfs is available!")
70-
return ipfsInstance
71-
}
66+
ipfsInstance = await loadWindowIpfs(permissions);
67+
if (ipfsInstance) {
68+
console.log("window.ipfs is available!");
69+
return ipfsInstance;
70+
}
7271

73-
console.log("window.ipfs is not available, downloading from CDN...");
74-
ipfsInstance = await loadJsIpfs();
75-
return ipfsInstance
72+
console.log("window.ipfs is not available, downloading from CDN...");
73+
ipfsInstance = await loadJsIpfs();
74+
return ipfsInstance;
7675
};
7776

7877
export default getIpfs;

0 commit comments

Comments
 (0)