Skip to content

Commit fc15262

Browse files
author
Dave Newman
committed
Disable chat on inactive streams
1 parent d980487 commit fc15262

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

app/assets/javascripts/components/Chat.es6.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Chat extends React.Component {
3737
}
3838

3939
renderChatInput() {
40-
if (this.props.signedIn && this.pusher) {
40+
if (this.props.active && this.pusher) {
4141
return (
4242
<form onSubmit={this.handleSubmit.bind(this)}>
4343
<input type="text" ref="body" defaultValue="" placeholder="Ask question" className="col-9 focus-no-border font-sm resize-chat-on-change m0" style={{"border": "none", "outline": "none"}} />
@@ -186,6 +186,6 @@ Chat.propTypes = {
186186
comments: React.PropTypes.array.isRequired,
187187
isLive: React.PropTypes.bool,
188188
pusherKey: React.PropTypes.string.isRequired,
189-
signedIn: React.PropTypes.bool,
189+
active: React.PropTypes.bool,
190190
stream: React.PropTypes.object.isRequired,
191191
}

app/controllers/streams_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def update
3232
def show
3333
if params[:username]
3434
@user = User.find_by!(username: params[:username])
35-
if @stream = @user.streams.order(created_at: :desc).first!
35+
if @stream = @user.active_stream
3636
@stream.broadcasting = !!cached_stats
3737
end
3838
else

app/models/stream.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def archived?
4242
!!archived_at
4343
end
4444

45+
def active
46+
published? && !archived?
47+
end
48+
4549
def preview_image_url
4650
"https://api.quickstream.io/coderwall/streams/#{user.username}.png?size=400x"
4751
end

app/views/streams/show.json.jbuilder

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ if current_user
22
json.authorUrl user_path(current_user)
33
json.authorUsername current_user.username
44
end
5-
json.signedIn !!current_user
65
json.pusherKey ENV['PUSHER_KEY']
76
json.chatChannel @stream.dom_id
87

98
json.stream do
10-
json.extract! @stream, :id
9+
json.extract! @stream, :id, :active
1110
end
1211

1312
json.comments @comments, partial: 'comments/comment', as: :comment

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy