Commit bebb4793 authored by roadscape's avatar roadscape
Browse files

fix subscribe

parent e88f0f26
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
word-break: break-all; word-break: break-all;
text-align: left; text-align: left;
} }
}
.community--error { .community--error {
color: rgb(199, 37, 78); color: rgb(199, 37, 78);
}
} }
...@@ -20,7 +20,7 @@ const generateAuth = (user, pass, type) => { ...@@ -20,7 +20,7 @@ const generateAuth = (user, pass, type) => {
}; };
}; };
const generateHivemindOperation = (action, params, actor_name) => { const generateHivemindOperation = (actor_name, action, params) => {
return [ return [
'custom_json', 'custom_json',
{ {
...@@ -55,7 +55,10 @@ export function* customOps(action) { ...@@ -55,7 +55,10 @@ export function* customOps(action) {
createAccountErrorCB, createAccountErrorCB,
broadcastOpsErrorCB, broadcastOpsErrorCB,
} = action.payload; } = action.payload;
// wait 3s for account creation to settle
yield call(wait, 3000); yield call(wait, 3000);
try { try {
const communityOwnerPosting = auth.getPrivateKeys( const communityOwnerPosting = auth.getPrivateKeys(
communityOwnerName, communityOwnerName,
...@@ -64,17 +67,17 @@ export function* customOps(action) { ...@@ -64,17 +67,17 @@ export function* customOps(action) {
); );
const setRoleOperation = generateHivemindOperation( const setRoleOperation = generateHivemindOperation(
communityOwnerName,
'setRole', 'setRole',
{ {
community: communityOwnerName, community: communityOwnerName,
account: accountName, account: accountName,
role: 'admin', role: 'admin',
}, }
communityOwnerName,
communityOwnerPosting
); );
const updatePropsOperation = generateHivemindOperation( const updatePropsOperation = generateHivemindOperation(
communityOwnerName,
'updateProps', 'updateProps',
{ {
community: communityOwnerName, community: communityOwnerName,
...@@ -82,28 +85,21 @@ export function* customOps(action) { ...@@ -82,28 +85,21 @@ export function* customOps(action) {
title: communityTitle, title: communityTitle,
about: communityDescription, about: communityDescription,
}, },
}, }
communityOwnerName,
communityOwnerPosting
); );
const subscribeToCommunityOperation = generateHivemindOperation( const subscribeToCommunityOperation = generateHivemindOperation(
accountName,
'subscribe', 'subscribe',
{ {
community: communityOwnerName, community: communityOwnerName,
}, }
communityOwnerName,
communityOwnerPosting
); );
yield broadcast.sendAsync( yield broadcast.sendAsync(
{ {
extensions: [], extensions: [],
operations: [ operations: [setRoleOperation, updatePropsOperation],
setRoleOperation,
updatePropsOperation,
subscribeToCommunityOperation,
],
}, },
[ [
auth.toWif( auth.toWif(
...@@ -114,6 +110,21 @@ export function* customOps(action) { ...@@ -114,6 +110,21 @@ export function* customOps(action) {
] ]
); );
// subscription op must be broadcast from logged in user
yield put(
transactionActions.broadcastOperation({
type: subscribeToCommunityOperation[0],
operation: subscribeToCommunityOperation[1],
successCallback: res => {
console.log('subscribed');
},
errorCallback: res => {
console.log('subscribe error', res);
},
})
);
// wait a few blocks for hivemind to index ops before alerting user
yield call(wait, 6000); yield call(wait, 6000);
yield put({ yield put({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment