rename calls -> api

This commit is contained in:
Pavel Murygin 2021-01-16 16:28:00 +03:00
parent f7e57bf9b3
commit 98d3cfd990
3 changed files with 12 additions and 12 deletions

View File

@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react';
import './App.scss'; import './App.scss';
import { FluenceClientContext } from '../app/FluenceClientContext'; import { FluenceClientContext } from '../app/FluenceClientContext';
import { UserList } from './UserList'; import { UserList } from './UserList';
import * as calls from 'src/app/api'; import * as api from 'src/app/api';
import { CollaborativeEditor } from './CollaborativeEditor'; import { CollaborativeEditor } from './CollaborativeEditor';
import { relayNode } from 'src/app/constants'; import { relayNode } from 'src/app/constants';
@ -27,7 +27,7 @@ const App = () => {
return; return;
} }
await calls.join(client, nickName); await api.join(client, nickName);
setIsInRoom(true); setIsInRoom(true);
}; };
@ -36,7 +36,7 @@ const App = () => {
return; return;
} }
await calls.leave(client); await api.leave(client);
setIsInRoom(false); setIsInRoom(false);
}; };
@ -53,7 +53,7 @@ const App = () => {
</div> </div>
<div className="header-item"> <div className="header-item">
<button className="button" onClick={() => calls.clean(client!)}> <button className="button" onClick={() => api.clean(client!)}>
Clean Clean
</button> </button>
</div> </div>

View File

@ -5,7 +5,7 @@ import { subscribeToEvent } from '@fluencelabs/fluence';
import { fluentPadServiceId, notifyTextUpdateFnName } from 'src/app/constants'; import { fluentPadServiceId, notifyTextUpdateFnName } from 'src/app/constants';
import { useFluenceClient } from '../app/FluenceClientContext'; import { useFluenceClient } from '../app/FluenceClientContext';
import { getUpdatedDocFromText, initDoc, SyncClient } from '../app/sync'; import { getUpdatedDocFromText, initDoc, SyncClient } from '../app/sync';
import * as calls from 'src/app/api'; import * as api from 'src/app/api';
const broadcastUpdates = _.debounce((text: string, syncClient: SyncClient) => { const broadcastUpdates = _.debounce((text: string, syncClient: SyncClient) => {
let doc = syncClient.getDoc(); let doc = syncClient.getDoc();
@ -29,7 +29,7 @@ export const CollaborativeEditor = () => {
syncClient.handleSendChanges = (changes: string) => { syncClient.handleSendChanges = (changes: string) => {
console.log('syncClient.handleSendChanges'); console.log('syncClient.handleSendChanges');
calls.addEntry(client, changes); api.addEntry(client, changes);
}; };
const unsub = subscribeToEvent(client, fluentPadServiceId, notifyTextUpdateFnName, (args, tetraplets) => { const unsub = subscribeToEvent(client, fluentPadServiceId, notifyTextUpdateFnName, (args, tetraplets) => {
@ -46,7 +46,7 @@ export const CollaborativeEditor = () => {
syncClient.start(); syncClient.start();
// don't block // don't block
calls.getHistory(client).then((res) => { api.getHistory(client).then((res) => {
for (let e of res) { for (let e of res) {
syncClient.receiveChanges(e.body); syncClient.receiveChanges(e.body);
} }

View File

@ -6,7 +6,7 @@ import {
notifyUserRemovedFnName, notifyUserRemovedFnName,
} from 'src/app/constants'; } from 'src/app/constants';
import { useFluenceClient } from '../app/FluenceClientContext'; import { useFluenceClient } from '../app/FluenceClientContext';
import * as calls from 'src/app/api'; import * as api from 'src/app/api';
import { subscribeToEvent } from '@fluencelabs/fluence'; import { subscribeToEvent } from '@fluencelabs/fluence';
type PeerId = string; type PeerId = string;
@ -42,11 +42,11 @@ export const UserList = (props: { selfName: string }) => {
}); });
// don't block // don't block
calls.updateOnlineStatuses(client); api.updateOnlineStatuses(client);
}, refreshTimeoutMs); }, refreshTimeoutMs);
const unsub1 = subscribeToEvent(client, fluentPadServiceId, notifyUserAddedFnName, (args, _) => { const unsub1 = subscribeToEvent(client, fluentPadServiceId, notifyUserAddedFnName, (args, _) => {
const users = args.flatMap((x) => x).flatMap((x) => x) as calls.User[]; const users = args.flatMap((x) => x).flatMap((x) => x) as api.User[];
setUsers((prev) => { setUsers((prev) => {
const result = new Map(prev); const result = new Map(prev);
for (let u of users) { for (let u of users) {
@ -96,8 +96,8 @@ export const UserList = (props: { selfName: string }) => {
}); });
// don't block // don't block
calls.getUserList(client); api.getUserList(client);
calls.notifySelfAdded(client, props.selfName); api.notifySelfAdded(client, props.selfName);
return () => { return () => {
clearTimeout(listRefreshTimer); clearTimeout(listRefreshTimer);