-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open new Room #14
Open
KenavR
wants to merge
3
commits into
larvalabs:master
Choose a base branch
from
KenavR:open_channel
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Open new Room #14
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React, { Component } from 'react'; | ||
|
||
export class SidebarRoomHeader extends Component { | ||
constructor() { | ||
super(); | ||
this.toggleRoomInput = this.toggleRoomInput.bind(this); | ||
this.mouseOver = this.mouseOver.bind(this); | ||
this.mouseOut = this.mouseOut.bind(this); | ||
this.handleChange = this.handleChange.bind(this); | ||
this.handlePressedEnter = this.handlePressedEnter.bind(this); | ||
|
||
this.state = { | ||
value: '', | ||
hover: false, | ||
isInputVisible: false | ||
}; | ||
} | ||
|
||
getRoomInput() { | ||
const groupStyles = { margin: '5px 0' }; | ||
|
||
return ( | ||
<div className="input-group" style={groupStyles}> | ||
<div className="input-group-addon">#</div> | ||
<input type="text" className="form-control input-sm" placeholder="subreddit" | ||
value={ this.state.value } | ||
onChange={ this.handleChange } | ||
onKeyPress={ this.handlePressedEnter } | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
toggleRoomInput() { | ||
const isVisible = !this.state.isInputVisible; | ||
this.setState({ isInputVisible: isVisible }); | ||
if(!isVisible) this.setState({ value: "" }); | ||
|
||
} | ||
|
||
mouseOver() { | ||
this.setState({ hover: true }); | ||
} | ||
|
||
mouseOut() { | ||
this.setState({ hover: false }); | ||
} | ||
|
||
handleChange(event) { | ||
this.setState({ value: event.target.value }); | ||
} | ||
|
||
handlePressedEnter(event) { | ||
if (event.key === 'Enter') { | ||
const url = `${window.location.origin}/r/${this.state.value.trim()}`; | ||
window.location.href = url; | ||
} | ||
} | ||
|
||
render() { | ||
const hovered = (this.state.hover) ? { cursor: 'pointer' } : {}; | ||
const addBtnStyle = Object.assign({ float: 'right', fontSize: '1.1em' }, hovered); | ||
const { styles } = this.props; | ||
const iconClasses = (this.state.isInputVisible) ? 'fa fa-close' : 'fa fa-plus'; | ||
|
||
return ( | ||
<div> | ||
<span style={styles}>Your Rooms</span> | ||
<span> | ||
<i style={addBtnStyle} className={iconClasses} | ||
onClick={this.toggleRoomInput} | ||
onMouseOver={this.mouseOver} | ||
onMouseOut={this.mouseOut} | ||
></i> | ||
</span> | ||
{(this.state.isInputVisible) ? this.getRoomInput() : null} | ||
</div> | ||
); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should trigger
chat-actions.handleChangeRoom
here instead of doing it manually to make sure we're changing rooms all in one play. AlsohandleChangeRoom
does some other things as well like update thelastMessageTime
for the room you change to.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that, but
handleChangeRoom
didn't work with rooms that weren't in the state. I could've changedchat-actions.handleChangeRoom
but I thought opening a room over the UI would be the same as using the url. This is also the way I open the room in the 'active rooms' #23 PR. I will take a look at it and update with the concrete issue.