mirror of
https://github.com/fluencelabs/fluent-pad
synced 2025-05-29 16:51:19 +00:00
fix fetch api calls' syntax
This commit is contained in:
parent
ff0b59fd47
commit
6d61678c91
@ -1,4 +1,4 @@
|
|||||||
import { FluenceClient, Particle, sendParticle } from '@fluencelabs/fluence';
|
import { FluenceClient, Particle, sendParticle, sendParticleAsFetch } from '@fluencelabs/fluence';
|
||||||
import {
|
import {
|
||||||
fluentPadServiceId,
|
fluentPadServiceId,
|
||||||
historyNodePid,
|
historyNodePid,
|
||||||
@ -149,20 +149,22 @@ export const getUserList = async (client: FluenceClient) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const join = async (client: FluenceClient, nickName: string) => {
|
export const join = async (client: FluenceClient, nickName: string) => {
|
||||||
let joinAir = `
|
const particle = new Particle(
|
||||||
|
`
|
||||||
(call userlistNode (userlist "join") [user] result)
|
(call userlistNode (userlist "join") [user] result)
|
||||||
`;
|
`,
|
||||||
|
{
|
||||||
const data = new Map();
|
user: {
|
||||||
data.set('user', {
|
|
||||||
name: nickName,
|
name: nickName,
|
||||||
peer_id: client.selfPeerId.toB58String(),
|
peer_id: client.selfPeerId.toB58String(),
|
||||||
relay_id: client.relayPeerID.toB58String(),
|
relay_id: client.relayPeerID.toB58String(),
|
||||||
});
|
},
|
||||||
data.set('userlist', userListServiceId);
|
userlist: userListServiceId,
|
||||||
data.set('userlistNode', userListNodePid);
|
userlistNode: userListNodePid,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const [result] = await client.fetch<[GetUsersResult]>(joinAir, ['result'], data);
|
const [result] = await sendParticleAsFetch(client, particle, ['result']);
|
||||||
throwIfError(result);
|
throwIfError(result);
|
||||||
return result.users;
|
return result.users;
|
||||||
};
|
};
|
||||||
@ -203,20 +205,22 @@ export const leaveRoom = async (client: FluenceClient) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getHistory = async (client: FluenceClient) => {
|
export const getHistory = async (client: FluenceClient) => {
|
||||||
let getHistoryAir = `
|
const particle = new Particle(
|
||||||
|
`
|
||||||
(seq
|
(seq
|
||||||
(call userlistNode (userlist "is_authenticated") [] token)
|
(call userlistNode (userlist "is_authenticated") [] token)
|
||||||
(call historyNode (history "get_all") [token.$.is_authenticated] entries)
|
(call historyNode (history "get_all") [token.$.["is_authenticated"]] entries)
|
||||||
)
|
)
|
||||||
`;
|
`,
|
||||||
|
{
|
||||||
|
userlist: userListServiceId,
|
||||||
|
history: historyServiceId,
|
||||||
|
userlistNode: userListNodePid,
|
||||||
|
historyNode: historyNodePid,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const data = new Map();
|
const [result] = await sendParticleAsFetch(client, particle, ['entries']);
|
||||||
data.set('userlist', userListServiceId);
|
|
||||||
data.set('history', historyServiceId);
|
|
||||||
data.set('userlistNode', userListNodePid);
|
|
||||||
data.set('historyNode', historyNodePid);
|
|
||||||
|
|
||||||
const [result] = await client.fetch<[GetEntries]>(getHistoryAir, ['entries'], data);
|
|
||||||
throwIfError(result);
|
throwIfError(result);
|
||||||
return result.entries;
|
return result.entries;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user