Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Add session name feature
Browse files Browse the repository at this point in the history
  • Loading branch information
e-jigsaw committed Jan 7, 2016
1 parent f910bf8 commit be12bb9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/actions/sessions.ls
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports.new-session = -> (dispatch, get-state)->
.sessions
.push do
created-at: new Date!.get-time!
name: 'unnamed session'
length: 0
(err)-> if err? then dispatch notify err

Expand All @@ -37,3 +38,11 @@ exports.delete-session = (key, dispatch, get-state)-->
.destroy!
.then -> dispatch notify \session-deleted
.catch (err)-> dispatch notify err

exports.rename-session = (key, new-name, dispatch, get-state)-->
{refs} = get-state!
refs
.sessions
.child key
.update do
name: new-name
6 changes: 5 additions & 1 deletion src/components/Rblg.ls
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require! {
\../actions/index.ls : {initialize, set-route}
\../actions/notification.ls : {set-notification}
\../actions/auth.ls : {check-auth, auth, unauth}
\../actions/sessions.ls : {update-sessions, new-session, delete-session}
\../actions/sessions.ls : {update-sessions, new-session, delete-session, rename-session}
\../actions/session.ls : {attach-session, next-post, prev-post, reblog, like}
\../actions/config.ls : {update-config-tumblr, save-config-tumblr}
\./Menu.ls
Expand Down Expand Up @@ -62,6 +62,10 @@ class Rblg extends Component
attach-session: (session-id)~> ~>
@props.dispatch attach-session session-id
@props.dispatch set-route \session
rename-session: (session-id)~> (event)~>
if event.key-code is 13
event.target.blur!
@props.dispatch rename-session session-id, event.target.value
delete-session: (session-id)~> ~> @props.dispatch delete-session session-id
| \session =>
create-element do
Expand Down
21 changes: 17 additions & 4 deletions src/components/Sessions.ls
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,44 @@ class Sessions extends Component
margin: 0
padding: 0
@props.sessions.map (session, i)~>
created-at = new Date session.created-at
DOM.li do
key: "session-#{i}"
key: "session-#{session.id}"
style:
background-color: \#4747EB
list-style-type: \none
margin-bottom: \5px
DOM.input do
style:
margin-bottom: \-10px
padding: 0
font-size: \24px
color: \#fff
background-color: 'rgba(0, 0, 0, 0)'
border: 0
on-key-down: @props.rename-session session.id
default-value: session.name
DOM.p do
style:
margin: 0
padding: 0
font-size: \24px
font-size: \12px
color: \#fff
new Date session.created-at .toString!
"#{created-at.getFullYear!}/#{created-at.getMonth! + 1}/#{created-at.getDate!} #{created-at.getHours!}:#{created-at.getMinutes!}"
DOM.button do
className: 'pure-button'
style:
width: \60%
background-color: \#1CB841
color: \#fff
font-size: \18px
font-size: \24px
padding: \5px
on-click: @props.attach-session session.id
DOM.i do
className: 'fa fa-link'
style:
margin-right: \5px
font-size: \24px
\Attach
DOM.button do
className: 'pure-button'
Expand Down

0 comments on commit be12bb9

Please sign in to comment.