<commit_before>Client = require 'hangupsjs'

merge   = (t, os...) -> t[k] = v for k,v of o when v not in [null, undefined] for o in os; t

{throttle, later, tryparse} = require '../util'

STATES =
    STATE_STARTUP: 'startup'
    STATE_NORMAL: 'normal'
    STATE_ADD_CONVERSATION: 'add_conversation'

module.exports = exp = {
    state: null
    attop: false   # tells whether message list is scrolle to top
    atbottom: true # tells whether message list is scrolled to bottom
    selectedConv: localStorage.selectedConv
    lastActivity: null
    leftSize: tryparse(localStorage.leftSize) ? 200
    size: tryparse(localStorage.size ? "[940, 600]")
    pos: tryparse(localStorage.pos ? "[100, 100]")
    showConvThumbs: tryparse(localStorage.showConvThumbs)

    setState: (state) ->
        return if @state == state
        @state = state
        if state == STATES.STATE_STARTUP
            # set a first active timestamp to avoid requesting
            # syncallnewevents on startup
            require('./connection').setLastActive(Date.now(), true)
        updated 'viewstate'

    setSelectedConv: (c) ->
        conv = require './conv' # circular
        conv_id = c?.conversation_id?.id ? c?.id ? c
        unless conv_id
            conv_id = conv.list()?[0]?.conversation_id?.id
        return if @selectedConv == conv_id
        @selectedConv = localStorage.selectedConv = conv_id
        @setLastKeyDown 0
        updated 'viewstate'
        updated 'switchConv'

    selectNextConv: (offset = 1) ->
        id = @selectedConv
        list = conv.list()
        for c, index in list
            if id == c.conversation_id.id<commit_msg>fix missing require<commit_after>Client = require 'hangupsjs'

merge   = (t, os...) -> t[k] = v for k,v of o when v not in [null, undefined] for o in os; t

{throttle, later, tryparse} = require '../util'

STATES =
    STATE_STARTUP: 'startup'
    STATE_NORMAL: 'normal'
    STATE_ADD_CONVERSATION: 'add_conversation'

module.exports = exp = {
    state: null
    attop: false   # tells whether message list is scrolle to top
    atbottom: true # tells whether message list is scrolled to bottom
    selectedConv: localStorage.selectedConv
    lastActivity: null
    leftSize: tryparse(localStorage.leftSize) ? 200
    size: tryparse(localStorage.size ? "[940, 600]")
    pos: tryparse(localStorage.pos ? "[100, 100]")
    showConvThumbs: tryparse(localStorage.showConvThumbs)

    setState: (state) ->
        return if @state == state
        @state = state
        if state == STATES.STATE_STARTUP
            # set a first active timestamp to avoid requesting
            # syncallnewevents on startup
            require('./connection').setLastActive(Date.now(), true)
        updated 'viewstate'

    setSelectedConv: (c) ->
        conv = require './conv' # circular
        conv_id = c?.conversation_id?.id ? c?.id ? c
        unless conv_id
            conv_id = conv.list()?[0]?.conversation_id?.id
        return if @selectedConv == conv_id
        @selectedConv = localStorage.selectedConv = conv_id
        @setLastKeyDown 0
        updated 'viewstate'
        updated 'switchConv'

    selectNextConv: (offset = 1) ->
        conv = require './conv'
        id = @selectedConv
        list = conv.list()
        for c, index in list
            if id == c.conversation_id.id
{'fraction_non_alphanumeric': 0.10575194727381666, 'fraction_numerical': 0.01078490113840623, 'mean_word_length': 2.5483528161530287, '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': '4488190', 'n_tokens_mistral': 1035, 'n_tokens_neox': 986, 'n_words': 292}