Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
condenser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
condenser
Commits
7ac68207
Commit
7ac68207
authored
4 years ago
by
Dan Notestein
Browse files
Options
Downloads
Plain Diff
Merge branch 'revert-
512fdc05
' into 'develop'
Revert "Merge branch 'revert-
fb249eac
' into 'develop'" See merge request
!113
parents
0f4b4fa4
ab10c520
No related branches found
Branches containing commit
No related tags found
2 merge requests
!120
Develop
,
!113
Revert "Merge branch 'revert-fb249eac' into 'develop'"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/redux/UserProfilesSaga.js
+7
-2
7 additions, 2 deletions
src/app/redux/UserProfilesSaga.js
src/app/utils/steemApi.js
+35
-1
35 additions, 1 deletion
src/app/utils/steemApi.js
with
42 additions
and
3 deletions
src/app/redux/UserProfilesSaga.js
+
7
−
2
View file @
7ac68207
import
{
call
,
put
,
takeLatest
}
from
'
redux-saga/effects
'
;
import
*
as
userProfileActions
from
'
./UserProfilesReducer
'
;
import
{
callBridge
}
from
'
app/utils/steemApi
'
;
import
{
callBridge
,
getHivePowerForUser
}
from
'
app/utils/steemApi
'
;
const
FETCH_PROFILE
=
'
userProfilesSaga/FETCH_PROFILE
'
;
...
...
@@ -11,9 +11,14 @@ export const userProfilesWatches = [
export
function
*
fetchUserProfile
(
action
)
{
const
{
account
,
observer
}
=
action
.
payload
;
const
ret
=
yield
call
(
callBridge
,
'
get_profile
'
,
{
account
,
observer
});
const
hive_power
=
yield
getHivePowerForUser
(
account
);
if
(
!
ret
)
throw
new
Error
(
'
Account not found
'
);
yield
put
(
userProfileActions
.
addProfile
({
username
:
account
,
account
:
ret
})
userProfileActions
.
addProfile
({
username
:
account
,
account
:
{
...
ret
,
stats
:
{
...
ret
.
stats
,
sp
:
hive_power
}
},
})
);
}
...
...
This diff is collapsed.
Click to expand it.
src/app/utils/steemApi.js
+
35
−
1
View file @
7ac68207
...
...
@@ -21,6 +21,32 @@ export async function callBridge(method, params) {
});
}
export
function
getHivePowerForUser
(
account
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
const
fullAccounts
=
await
api
.
callAsync
(
'
database_api.find_accounts
'
,
{
accounts
:
[
account
]
}
);
const
post_voting_power
=
fullAccounts
[
'
accounts
'
][
0
][
'
post_voting_power
'
];
/**
* This magic number is coming from
* https://gitlab.syncad.com/hive/hivemind/-/blame/d2d5ef25107908db09438da5ee3da9d6fcb976bc/hive/server/bridge_api/objects.py
*/
const
MAGIC_NUMBER
=
0.0005037
;
const
hive_power
=
(
post_voting_power
.
amount
*
MAGIC_NUMBER
*
(
1
/
Math
.
pow
(
10
,
post_voting_power
.
precision
))
).
toFixed
(
0
);
resolve
(
hive_power
);
}
catch
(
err
)
{
reject
(
err
);
}
});
}
export
async
function
getStateAsync
(
url
,
observer
,
ssr
=
false
)
{
console
.
log
(
'
getStateAsync
'
);
if
(
observer
===
undefined
)
observer
=
null
;
...
...
@@ -66,8 +92,16 @@ export async function getStateAsync(url, observer, ssr = false) {
if
(
ssr
&&
account
)
{
// TODO: move to global reducer?
const
profile
=
await
callBridge
(
'
get_profile
'
,
{
account
});
const
hive_power
=
await
getHivePowerForUser
(
account
);
if
(
profile
&&
profile
[
'
name
'
])
{
state
[
'
profiles
'
][
account
]
=
profile
;
state
[
'
profiles
'
][
account
]
=
{
...
profile
,
stats
:
{
...
profile
.
stats
,
sp
:
hive_power
,
},
};
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment