 
     startDrag = (e) ->
       adj = e.clientX - clientX
+      result = initWidth + adj
 
-      sidebar.style.width = "#{(initWidth + adj)}px"
-      bottom.style.width = "#{(initWidth + adj) - 1}px"
+      sidebar.style.width = "#{result}px"
+      bottom.style.width = "#{result - 1}px"
+
+      # Save sidebar width
+      localStorage.setItem('zenit:sidebar-width', result)
       
     stopDrag = (e) ->
       document.documentElement.removeEventListener 'mousemove', startDrag, false


class Sidebar extends React.Component
  @displayName = 'Sidebar'

  onQuickConnect: ->
    ApplicationActions.loadView('connection')

    document.documentElement.addEventListener 'mouseup', stopDrag, false

  render: =>
    sidebarStyles =
      width: "#{@cachedSidebarWidth}px" if @cachedSidebarWidth

    bottomStyles =
      width: "#{@cachedSidebarWidth - 1}px" if @cachedSidebarWidth

    <div className="sidebar-inner" style={sidebarStyles} ref="sidebar">
      <a className="quick-connect-link" onClick={@onQuickConnect}><span className="octicon octicon-zap"></span> Quick connect</a>

      <span className="divider"></span>
