add fixes'

This commit is contained in:
Sasha 2023-11-29 11:57:08 +01:00
parent 1923b3637e
commit 1370a6d0c4
No known key found for this signature in database
3 changed files with 19 additions and 13 deletions

View File

@ -109,9 +109,12 @@ export class RLN implements IRLN {
private initKeystore(): Keystore {
const localKeystoreString = localStorage.getItem("keystore");
const _keystore = Keystore.fromString(localKeystoreString || "");
return _keystore || Keystore.create();
try {
return Keystore.fromString(localKeystoreString || "");
} catch(error) {
return Keystore.create();
}
}
public addEventListener(name: RLNEventsNames, fn: EventListener) {

View File

@ -53,7 +53,7 @@ class Relay {
this.subscriptionRoutine = window.setInterval(async () => {
await this.fetchMessages();
}, SECOND);
}, 10 * SECOND);
this.contentTopicListeners.set(contentTopic, 1);
} catch (error) {
@ -83,8 +83,8 @@ class Relay {
this.contentTopicListeners.delete(contentTopic);
}
private async fetchMessages(): Promise<void> {
const contentTopic = Object.keys(this.contentTopicListeners)[0];
private async fetchMessages(): Promise<any> {
const contentTopic = Array.from(this.contentTopicListeners.keys())[0];
if (!contentTopic) {
return;

View File

@ -5,9 +5,7 @@ export const http = {
mode: "no-cors",
referrerPolicy: "no-referrer",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*",
'Content-Type': 'text/plain',
},
body: JSON.stringify(body)
});
@ -18,14 +16,19 @@ export const http = {
mode: "no-cors",
referrerPolicy: "no-referrer",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*",
'Content-Type': 'text/plain',
},
body: JSON.stringify(body)
});
},
get(url: string) {
return fetch(new URL(url));
return fetch(new URL(url), {
method: "GET",
mode: "no-cors",
referrerPolicy: "no-referrer",
headers: {
'Content-Type': 'text/plain'
},
});
}
};