Skip to content

Commit

Permalink
Merge branch 'master' of github.com:RocketChat/Rocket.Chat
Browse files Browse the repository at this point in the history
Conflicts:
	i18n/en.i18n.json
  • Loading branch information
gmsecrieru committed Sep 11, 2015
2 parents 39d8479 + 4a546a1 commit 8650837
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 20 deletions.
2 changes: 1 addition & 1 deletion client/lib/RoomManager.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
loadMissedMessages = (rid) ->
lastMessage = ChatMessage.findOne({rid: 'GENERAL'}, {sort: {ts: -1}, limit: 1})
lastMessage = ChatMessage.findOne({rid: rid}, {sort: {ts: -1}, limit: 1})
if not lastMessage?
return

Expand Down
5 changes: 4 additions & 1 deletion client/lib/jquery.swipebox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 29 additions & 1 deletion client/lib/menu.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@menu = new class
init: ->
@container = $("#rocket-chat")
@list = $('.rooms-list')

isOpen: ->
return @container?.hasClass("menu-opened") is true
Expand All @@ -17,4 +18,31 @@
if @isOpen()
@close()
else
@open()
@open()

updateUnreadBars: _.throttle ->
if not @list?
return

listOffset = @list.offset()
listHeight = @list.height()

showTop = false
showBottom = false
$('li.has-alert').each ->
if $(this).offset().top < listOffset.top - $(this).height()
showTop = true

if $(this).offset().top > listOffset.top + listHeight
showBottom = true

if showTop is true
$('.top-unread-rooms').removeClass('hidden')
else
$('.top-unread-rooms').addClass('hidden')

if showBottom is true
$('.bottom-unread-rooms').removeClass('hidden')
else
$('.bottom-unread-rooms').addClass('hidden')
, 200
2 changes: 2 additions & 0 deletions client/startup/unread.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Meteor.startup ->

readMessage.refreshUnreadMark(subscription.rid)

menu.updateUnreadBars()

if unreadCount > 0
if unreadCount > 999
Session.set 'unread', '999+'
Expand Down
41 changes: 39 additions & 2 deletions client/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,35 @@ a.github-fork {
font-size: 12px;
}
}
.unread-rooms {
background-color: #068FE4;
position: absolute;
z-index: 1000;
width: 100%;
text-align: center;
line-height: 24px;
color: white;
text-transform: uppercase;
font-weight: bold;
display: -webkit-flex;
display: flex;
align-items: center;
-webkit-align-items: center;
justify-content: center;
-webkit-justify-content: center;

&.top-unread-rooms {
top: 60px;
}
&.bottom-unread-rooms {
bottom: 70px;
}

i {
margin-left: 5px;
font-size: 12px;
}
}
}

.new-room-highlight a {
Expand Down Expand Up @@ -2157,12 +2186,19 @@ a.github-fork {
height: 23px;
font-size: 11px;
padding: 3px;
display: inline-block;
white-space: nowrap;
display: -webkit-flex;
display: flex;
align-items: center;
overflow: hidden;
position: absolute;
right: 20px;
opacity: .5;
.transition(opacity .2 linear);
> * {
margin: 0 3px;
}
&:hover {
opacity: 1;
}
q {
padding: 0 0 0 3px;
Expand Down Expand Up @@ -3386,6 +3422,7 @@ a.github-fork {
border-radius: 4px;
padding: 0px 3px 2px 2px;
font-weight: bold;
border: 1px solid #8FD1F9;
}

.avatar-suggestions {
Expand Down
5 changes: 1 addition & 4 deletions client/stylesheets/utils/_colors.import.less
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,7 @@ a.github-fork {
background: #FCFCFC;
}
.formatting-tips {
color: #888888;
&:hover {
color: #444444;
}
color: #444444;
q {
border-left-color: #ccc;
}
Expand Down
6 changes: 6 additions & 0 deletions client/views/app/sideNav/sideNav.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Template.sideNav.events
'mouseleave .header': ->
SideNav.leaveArrow()

'scroll .rooms-list': ->
menu.updateUnreadBars()

Template.sideNav.onRendered ->
SideNav.init()
menu.init()

Meteor.defer ->
menu.updateUnreadBars()
6 changes: 6 additions & 0 deletions client/views/app/sideNav/sideNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{{> userStatus}}
</header>
{{#if currentUser}}
<div class="unread-rooms top-unread-rooms hidden">
{{_ "More_unreads"}} <i class="icon-up-big"></i>
</div>
<div class="rooms-list">
<div class="wrapper">
{{> starredRooms }}
Expand All @@ -15,6 +18,9 @@ <h3>
</h3>
</div>
</div>
<div class="unread-rooms bottom-unread-rooms hidden">
{{_ "More_unreads"}} <i class="icon-down-big"></i>
</div>
<div class="flex-nav hidden">
<section>
{{> UI.dynamic template=flexTemplate data=flexData}}
Expand Down
2 changes: 2 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"Add_users" : "Add users",
"Administration" : "Administration",
"All_channels" : "All channels",
"Allow_Invalid_SelfSigned_Certs": "Allow invalid and Self-Signed SSL certificate's for link validation and previews",
"and" : "and",
"API_Analytics" : "Analytics",
"API_Embed" : "Embed",
Expand Down Expand Up @@ -170,6 +171,7 @@
"minutes" : "minutes",
"More_channels" : "More channels",
"More_groups" : "More private groups",
"More_unreads" : "More unreads",
"Msgs" : "Msgs",
"multi" : "multi",
"My_Account" : "My Account",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/settings/server/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Meteor.startup ->

RocketChat.settings.addGroup 'General'
RocketChat.settings.add 'Site_Name', 'Rocket.Chat', { type: 'string', group: 'General', public: true }
RocketChat.settings.add 'Allow_Invalid_SelfSigned_Certs', false, { type: 'boolean', group: 'General' }

RocketChat.settings.addGroup 'API'
RocketChat.settings.add 'API_Analytics', '', { type: 'string', group: 'API', public: true }
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-oembed/server/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ getUrlContent = (urlObj, redirectCount = 5, callback) ->
port: urlObj.port
hostname: urlObj.hostname
path: urlObj.path
rejectUnauthorized: !RocketChat.settings.get 'Allow_Invalid_SelfSigned_Certs'

httpOrHttps = if urlObj.protocol is 'https:' then https else http

Expand Down
29 changes: 29 additions & 0 deletions server/methods/archiveRoom.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Meteor.methods
archiveRoom: (rid) ->
if not Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] archiveRoom -> Invalid user'

console.log '[methods] archiveRoom -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments

room = ChatRoom.findOne rid

if room.u? and room.u._id is Meteor.userId() or Meteor.user().admin?
update =
$set:
archived: true

ChatRoom.update rid, update

for username in room.usernames
member = Meteor.users.findOne({ username: username },{ fields: { username: 1 }})
if not member?
continue

ChatSubscription.update
rid: rid
'u._id': member._id
,
$set:
alert: false
open: false
archived: true
18 changes: 7 additions & 11 deletions server/methods/deleteMessage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Meteor.methods
keepHistory = RocketChat.settings.get 'Message_KeepHistory'
showDeletedStatus = RocketChat.settings.get 'Message_ShowDeletedStatus'

deleteQuery =
_id: message._id
deleteQuery['u._id'] = Meteor.userId() if user?.admin isnt true

if keepHistory
if showDeletedStatus
history = ChatMessage.findOne message._id
Expand All @@ -25,24 +29,16 @@ Meteor.methods
delete history._id
ChatMessage.insert history
else
ChatMessage.update
_id: message._id
'u._id': Meteor.userId()
,
ChatMessage.update deleteQuery,
$set:
_hidden: true

else
if not showDeletedStatus
ChatMessage.remove
_id: message._id
'u._id': Meteor.userId()
ChatMessage.remove deleteQuery

if showDeletedStatus
ChatMessage.update
_id: message._id
'u._id': Meteor.userId()
,
ChatMessage.update deleteQuery,
$set:
msg: ''
t: 'rm'
Expand Down
29 changes: 29 additions & 0 deletions server/methods/unarchiveRoom.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Meteor.methods
unArchiveRoom: (rid) ->
if not Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] unArchiveRoom -> Invalid user'

console.log '[methods] unArchiveRoom -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments

room = ChatRoom.findOne rid

if room.u? and room.u._id is Meteor.userId() or Meteor.user().admin?
update =
$set:
archived: false

ChatRoom.update rid, update

for username in room.usernames
member = Meteor.users.findOne({ username: username },{ fields: { username: 1 }})
if not member?
continue

ChatSubscription.update
rid: rid
'u._id': member._id
,
$set:
alert: false
open: false
archived: false

0 comments on commit 8650837

Please sign in to comment.