mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-29 04:04:02 +03:00
btc: fix issue with channel-js resubscribes
This commit is contained in:
parent
62afe28f3f
commit
99a44640f0
@ -8,18 +8,16 @@ import './css/indigo-static.css';
|
||||
import './css/fonts.css';
|
||||
import './css/custom.css';
|
||||
|
||||
api.setAuthTokens({
|
||||
ship: window.ship
|
||||
});
|
||||
window.NETWORK = 'testnet'; // 'bitcoin'
|
||||
|
||||
window.urb = new window.channel();
|
||||
const channel = new window.channel();
|
||||
api.setChannel(window.ship, channel);
|
||||
|
||||
subscription.start();
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept()
|
||||
}
|
||||
|
||||
ReactDOM.render((
|
||||
<Root />
|
||||
<Root channel={channel}/>
|
||||
), document.querySelectorAll("#root")[0]);
|
||||
|
@ -1,15 +1,16 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
class UrbitApi {
|
||||
setAuthTokens(authTokens) {
|
||||
this.authTokens = authTokens;
|
||||
setChannel(ship, channel) {
|
||||
this.ship = ship;
|
||||
this.channel = channel;
|
||||
this.bindPaths = [];
|
||||
}
|
||||
|
||||
bind(path, method, ship = this.authTokens.ship, appl = "btc-wallet", success, fail) {
|
||||
bind(path, method, ship = this.ship, appl = "btc-wallet", success, fail) {
|
||||
this.bindPaths = _.uniq([...this.bindPaths, path]);
|
||||
|
||||
window.subscriptionId = window.urb.subscribe(ship, appl, path,
|
||||
window.subscriptionId = this.channel.subscribe(ship, appl, path,
|
||||
(err) => {
|
||||
fail(err);
|
||||
},
|
||||
@ -33,7 +34,7 @@ class UrbitApi {
|
||||
|
||||
action(appl, mark, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.urb.poke(ship, appl, mark, data,
|
||||
this.channel.poke(ship, appl, mark, data,
|
||||
(json) => {
|
||||
resolve(json);
|
||||
},
|
||||
|
@ -12,6 +12,7 @@ import StartupModal from './lib/startupModal.js';
|
||||
import Header from './lib/header.js'
|
||||
import Balance from './lib/balance.js'
|
||||
import Transactions from './lib/transactions.js'
|
||||
import { subscription } from '../subscription.js'
|
||||
|
||||
|
||||
export class Root extends Component {
|
||||
@ -23,6 +24,13 @@ export class Root extends Component {
|
||||
console.log('state', this.state);
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
this.props.channel.setOnChannelError((e) => {
|
||||
subscription.start();
|
||||
});
|
||||
subscription.start();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
@ -53,4 +61,3 @@ export class Root extends Component {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user