Lunie: Move balances, rewards queries to Store (and probably also delegations & undelegations)

Created on 28 May 2020  路  11Comments  路  Source: luniehq/lunie

Is your feature request related to a problem? Please describe.

I think in itself it helps code reduction and simplification, gives us more control (same query all accross the app, not five different skips, missing updates and so on...). So I think it is good in itself.

But also could be a final solution for the bugs we are currently experiencing with mixing balances both in TmBalance and ActionModal from different networks / sessions.

Describe the solution you'd like

Move all session/account related queries (balances, rewards, delegations and undelegations) to store. To the session module concretely.

To update these values we would have like now, in blockAdded in TmBalance, except instead of an $apollo.refetch it would be a $store.dispatch

Describe alternatives you've considered

Leave it like it is? We have four balances queries across Lunie. Probably they get cached, but we are not so sure how this actually works. And why have code replication?

Additional context

All 11 comments

Another error related to the same, rewards not being updated in this case across networks:

image

If we go to the function, we see that it is searching for a reward that matches the stakingDenom, but the rewards it is searching in are the old ones, from another network, so it cannot find any and thus these errors:

    filterStakingDenomReward() {
      if (this.rewards && this.rewards.length > 0) {
        const stakingDenomRewards = this.rewards.filter(
          (reward) => reward.denom === this.stakingDenom
        )
        return stakingDenomRewards[0].amount
      }
    },

So we are going for it?

Or for now we fix all this with the dynamic refs?

I'd go for it

up to you and @faboweb

Let's find the actual bug.

Let's find the actual bug.

OK, and after that we do this! 馃ぉ Because it is just cleaner

I think we really should do this

I like this solution, should improve UX and reduce the number of API queries.

I still think this makes more sense than the current architecture

https://github.com/luniehq/lunie/issues/4157#issuecomment-636903834

:P I don't think creating an own apollo caching implementation will be cleaner than theirs

:P I don't think creating an own apollo caching implementation will be cleaner than theirs

I just think it is cleaner, more beautiful architecture and gives us more control over everything :shrug:

Well, maybe this is not something we will have the time to do for a long time, so closing for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faboweb picture faboweb  路  3Comments

faboweb picture faboweb  路  3Comments

AdityaSripal picture AdityaSripal  路  4Comments

fedekunze picture fedekunze  路  3Comments

okwme picture okwme  路  3Comments