mirror of
https://github.com/fluencelabs/fluid
synced 2025-03-15 18:50:48 +00:00
small refactoring
This commit is contained in:
parent
53c30d4671
commit
2146507ed9
@ -1,4 +1,4 @@
|
||||
import {getMessages, saveMessage} from "../fluence/api";
|
||||
import {changeConnection, getMessages, saveMessage} from "../fluence/api";
|
||||
import { showLoading, hideLoading } from "react-redux-loading-bar";
|
||||
|
||||
export const ADD_MESSAGE = "ADD_MESSAGE";
|
||||
@ -11,18 +11,15 @@ function addMessage(message) {
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchPosts(counter, withBar) {
|
||||
return dispatch => {
|
||||
if (withBar) {
|
||||
dispatch(showLoading());
|
||||
export async function toggleConnection(devnet, appId = 412) {
|
||||
return changeConnection(devnet, appId)
|
||||
}
|
||||
|
||||
export function fetchPosts(counter) {
|
||||
return dispatch => {
|
||||
return getMessages().then((messages) => {
|
||||
dispatch(receiveMessages(messages, counter));
|
||||
}).finally(() => {
|
||||
if (withBar) {
|
||||
dispatch(hideLoading());
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, {Component} from "react";
|
||||
import {connect} from "react-redux";
|
||||
import {toggleConnection} from "../fluence/api";
|
||||
import {toggleConnection} from "../actions/messages";
|
||||
|
||||
class ConnectionToggle extends Component {
|
||||
constructor(props) {
|
||||
@ -20,7 +20,7 @@ class ConnectionToggle extends Component {
|
||||
toggleDisabled: true,
|
||||
devnetConnect: newConnect
|
||||
}));
|
||||
toggleConnection(newConnect).finally(() => {
|
||||
toggleConnection(newConnect).then(() => {
|
||||
this.setState(state => ({
|
||||
toggleDisabled: false
|
||||
}));
|
||||
|
@ -12,11 +12,11 @@ class Dashboard extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.dispatch(handleInitialData());
|
||||
this.pollingMessages = setInterval(
|
||||
() => this.getMessages(),
|
||||
2000
|
||||
1500
|
||||
);
|
||||
this.props.dispatch(handleInitialData());
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
@ -3,7 +3,7 @@ import * as fluence from "fluence";
|
||||
let session = fluence.directConnect("localhost", 30000, 1);
|
||||
window.fluenceSession = session;
|
||||
|
||||
export async function toggleConnection(devnet, appId = 412) {
|
||||
export async function changeConnection(devnet, appId = 412) {
|
||||
if (devnet) {
|
||||
fluence.connect("0xeFF91455de6D4CF57C141bD8bF819E5f873c1A01", appId).then((s) => {
|
||||
session = s;
|
||||
|
Loading…
x
Reference in New Issue
Block a user