Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Change to throttle sidebar UI on public page
Browse files Browse the repository at this point in the history
When connections change quickly the sidebar can flash and strobe, which
is annoying at best and inaccessible at worst. This commit throttles the
UI changes at a maximum of 1 change per second, which reduces the
unwanted behavior.

Note: The `throttle()` method from Mutant doesn't have tests or
documentation, so this is my best guess at how it's meant to be used
from reading the source code.
  • Loading branch information
christianbundy committed Dec 27, 2019
1 parent 30db888 commit bc49bc6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/depject/page/html/render/public.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const nest = require('depnest')
const { h, send, when, computed, map, onceTrue } = require('mutant')
const { h, send, when, computed, map, onceTrue, throttle } = require('mutant')

const slow = (input) => throttle(input, 1000)

exports.needs = nest({
sbot: {
Expand Down Expand Up @@ -158,7 +160,7 @@ exports.create = function (api) {
h('div', {
classList: 'ProfileList'
}, [
map(whoToFollow, (id) => {
map(slow(whoToFollow), (id) => {
return h('a.profile', {
href: id
}, [
Expand All @@ -179,7 +181,7 @@ exports.create = function (api) {
h('div', {
classList: 'ProfileList'
}, [
map(peers, peer => {
map(slow(peers), peer => {
const address = peer.address
const connected = peer.data.state === 'connected'
const id = peer.data.key
Expand Down Expand Up @@ -211,7 +213,7 @@ exports.create = function (api) {
h('div', {
classList: 'ProfileList'
}, [
map(peers, peer => {
map(slow(peers), peer => {
const id = peer.data.key
return h('a.profile', { href: id }, [
h('div.main', [
Expand Down

0 comments on commit bc49bc6

Please sign in to comment.