<commit_before>const nest = require('depnest')
const { h, computed, onceTrue, Value, watch } = require('mutant')
const merge = require('lodash/merge')

exports.gives = nest({
  'app.html.settings': true
})

exports.needs = nest({
  'app.html.settings': 'map',
  'config.sync.get': 'first',
  'config.sync.getCustom': 'first',
  'config.sync.setCustom': 'first'
})

const friendsHops = 2
exports.create = function (api) {
  return nest({
    'app.html.settings': friendHopsConnections
  })

  function friendHopsConnections () {
    let hops = Value(api.config.sync.get('friends.hops', friendsHops))
    hops.initial = hops()

    watch(hops, hops => {
      const intHops = parseInt(hops)
      updateConfig(intHops)
    })

    return {
      title: 'Friend Hops',
      body: h('FriendHops', [
        h('div.description', [
          'Specify whose content you replicate, and thus the size and shape of your network.'
        ]),
        h('div.slider', [
          h('datalist', { id: 'friends-hop-datalist' }, [
            h('option', { value: 0, label: '0 - Only your messages' }),
            h('option', { value: 1, label: '1 - You and your friend\'s messages' }),
            h('option', { value: 2, label: '2 - You, your friend\'s, and your friend\'s friend\'s  messages' }),
            h('option', { value: 3, label: '3 - You, your friend\'s, your friend\'s friend\'s, and their friend\'s messages' })
          ]),
          h('input', {
            type: 'range',
            attributes: { list: 'friends-hop-datalist' },
            min: 0,
            max: 3,
            value: hops,
            'ev-change': (ev) => hops.set(ev.target.value)
          })
        ]),
        computed(hops, (_hops) => {
          if (_hops === hops.initial) return
          return h('div.alert', [
            h('i.fa.fa-warning'),
            ' please restart patchbay for this to take effect'
          ])
        }),
      ])
    }

    function updateHops (hops) {
      onceTrue(api.sbot.obs.connection, sbot => {
        if (hops === go) pubs.set({})
        else {
          sbot.friendPub.pubsWithinHops(hops, (_, pubsInHops) => {
            pubs.set(pubsInHops)
          })
        }
      })
    }
  }

  function updateConfig (hops) {
    const configCustom = api.config.sync.getCustom()

    const next = merge({}, configCustom, {
      friends: { hops }
    })

    api.config.sync.setCustom(next)
  }
}<commit_msg>remove unnecessary function called updateHops<commit_after>const nest = require('depnest')
const { h, computed, onceTrue, Value, watch } = require('mutant')
const merge = require('lodash/merge')

exports.gives = nest({
  'app.html.settings': true
})

exports.needs = nest({
  'app.html.settings': 'map',
  'config.sync.get': 'first',
  'config.sync.getCustom': 'first',
  'config.sync.setCustom': 'first'
})

const friendsHops = 2
exports.create = function (api) {
  return nest({
    'app.html.settings': friendHopsConnections
  })

  function friendHopsConnections () {
    let hops = Value(api.config.sync.get('friends.hops', friendsHops))
    hops.initial = hops()

    watch(hops, hops => {
      const intHops = parseInt(hops)
      updateConfig(intHops)
    })

    return {
      title: 'Friend Hops',
      body: h('FriendHops', [
        h('div.description', [
          'Specify whose content you replicate, and thus the size and shape of your network.'
        ]),
        h('div.slider', [
          h('datalist', { id: 'friends-hop-datalist' }, [
            h('option', { value: 0, label: '0 - Only your messages' }),
            h('option', { value: 1, label: '1 - You and your friend\'s messages' }),
            h('option', { value: 2, label: '2 - You, your friend\'s, and your friend\'s friend\'s  messages' }),
            h('option', { value: 3, label: '3 - You, your friend\'s, your friend\'s friend\'s, and their friend\'s messages' })
          ]),
          h('input', {
            type: 'range',
            attributes: { list: 'friends-hop-datalist' },
            min: 0,
            max: 3,
            value: hops,
            'ev-change': (ev) => hops.set(ev.target.value)
          })
        ]),
        computed(hops, (_hops) => {
          if (_hops === hops.initial) return
          return h('div.alert', [
            h('i.fa.fa-warning'),
            ' please restart patchbay for this to take effect'
          ])
        }),
      ])
    }
  }

  function updateConfig (hops) {
    const configCustom = api.config.sync.getCustom()

    const next = merge({}, configCustom, {
      friends: { hops }
    })

    api.config.sync.setCustom(next)
  }
}
{'fraction_non_alphanumeric': 0.1598529093662124, 'fraction_numerical': 0.004758814622539477, 'mean_word_length': 2.1714677640603566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4916172', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1438, 'n_words': 351}