<commit_before>window.ReactSigninPopover = React.createClass
  getInitialState: ->
    opened: false

  componentDidMount: ->
    window.currentUser.on 'change:username', @_onSignedInChange, @

  componentWillUnmount: ->
    window.currentUser.off null, null, @

  _onButtonClicked: (e) ->
    @setState opened: true

  _onSignedInChange: ->
    if FactlinkApp.signedIn() && @state.opened
      @_callback()
      @setState opened: false

    @forceUpdate()

  submit: (callback) ->
    if FactlinkApp.signedIn()
      callback()
    else
      @setState opened: !@state.opened
      @_callback = callback

  render: ->
    if @state.opened && !FactlinkApp.signedIn()
      if window.localStorageIsEnabled
        ReactPopover className: 'white-popover', attachment: 'right',<commit_msg>Only open one signin popover at the time<commit_after>window.ReactSigninPopover = React.createClass
  getInitialState: ->
    opened: false

  componentDidMount: ->
    window.currentUser.on 'change:username', @_onSignedInChange, @
    FactlinkApp.vent.on 'ReactSigninPopover:opened', @_onOtherPopoverOpened, @

  componentWillUnmount: ->
    window.currentUser.off null, null, @
    FactlinkApp.vent.off null, null, @

  _onOtherPopoverOpened: (popover) ->
    return if popover == this

    @setState opened: false

  _onButtonClicked: (e) ->
    @setState opened: true

  _onSignedInChange: ->
    if FactlinkApp.signedIn() && @state.opened
      @_callback()
      @setState opened: false

    @forceUpdate()

  submit: (callback) ->
    if FactlinkApp.signedIn()
      callback()
    else
      opened = !@state.opened
      @setState opened: opened

      if opened
        @_callback = callback
        FactlinkApp.vent.trigger 'ReactSigninPopover:opened', this

  render: ->
    if @state.opened && !FactlinkApp.signedIn()
      if window.localStorageIsEnabled
        ReactPopover className: 'white-popover', attachment: 'right',
{'fraction_non_alphanumeric': 0.11220779220779221, 'fraction_numerical': 0.0, 'mean_word_length': 3.270509977827051, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '13231', 'n_tokens_mistral': 614, 'n_tokens_neox': 594, 'n_words': 126}