 
   toggle: -> atom.workspace.toggle(this)
 
-  toggleType: (type) ->
-    show = not @typesShown[type]
-    @typesShown[type] = show
-    button = @header.querySelector(".notification-type.#{type}")
-    @list.classList.toggle("hide-#{type}", not show)
-    button.classList.toggle('show-type', show)
+  toggleType: (type, force) ->
+    button = @element.querySelector(".notification-type.#{type}")
+    hide = not button.classList.toggle('show-type', force)
+    @list.classList.toggle("hide-#{type}", hide)
 
   addNotification: (notification) ->
     # TODO: should probably create new element instead of cloning

    @element.classList.add('notifications-log')

    # Add Header
    @header = document.createElement('header')
    @element.appendChild(@header)

    # Add Container
    @list = document.createElement('ul')
    @element.appendChild(@list)

    # Add Buttons
    for type, shown of @typesShown

      icon = switch type
        when 'fatal' then 'bug'
        when 'error' then 'flame'
        when 'warning' then 'alert'
        when 'info' then 'info'
        when 'success' then 'check'

      @list.classList.toggle("hide-#{type}", not shown)

      button = document.createElement('button')
      button.classList.add('notification-type', 'btn', 'icon', "icon-#{icon}", type)
      button.classList.toggle('show-type', shown)
      button.dataset.type = type
      button.addEventListener 'click', (e) => @toggleType(e.target.dataset.type)
      atom.tooltips.add(button, {title: "Toggle #{type} notifications"})
      @header.appendChild(button)

    # Add Notifications
    for notification in atom.notifications.getNotifications()

{Emitter} = require 'atom'

typeIcons =
  fatal: 'bug'
  error: 'flame'
  warning: 'alert'
  info: 'info'
  success: 'check'

module.exports = class NotificationsLog
  constructor: ->
    @render()
    @emitter = new Emitter
