Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
fix(status-tooltip): better syncing check algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus committed Jun 13, 2018
1 parent 660132c commit 7c2c072
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion app/components/status-tooltip/component.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import Component from '@ember/component';
import { get } from '@ember/object';

import InViewportMixin from 'ember-in-viewport';

import { service } from 'ember-decorators/service';
import { computed } from 'ember-decorators/object';
import { on } from 'ember-decorators/object/evented';
import { gt, lt } from 'ember-decorators/object/computed';

export default Component.extend(InViewportMixin, {
@service status: null,

@gt('status.blocks.unchecked', 0) hasUncheckedBlocks: false,
@lt('status.peers.length', 1) isPeerless: false,
@gt('uncheckedPercentage', 0.01) isSyncing: false,

@computed('status.blocks.{count,unchecked}')
get uncheckedPercentage() {
const status = this.get('status');
const count = get(status, 'blocks.count') || 0;
const unchecked = get(status, 'blocks.unchecked') || 1;
return (unchecked / count) * 100;
},

@on('didEnterViewport')
startPolling() {
Expand Down
6 changes: 3 additions & 3 deletions app/components/status-tooltip/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#fa-icon (if hasUncheckedBlocks 'refresh' 'signal')
spin=hasUncheckedBlocks
{{#fa-icon (if isSyncing 'refresh' 'signal')
spin=isSyncing
class=(if (not isPeerless) 'text-success')}}
{{#bs-tooltip}}
<ul class="m-0 list-unstyled">
Expand All @@ -9,7 +9,7 @@
{{#if isPeerless}}
{{t 'status.connecting'}}
{{else}}
{{if hasUncheckedBlocks (t 'syncing') (t 'status.online')}}
{{if isSyncing (t 'syncing') (t 'status.online')}}
{{/if}}
{{else}}
{{t 'status.connecting'}}
Expand Down

0 comments on commit 7c2c072

Please sign in to comment.