-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #496 from RocketChat/better-urls
Better urls
- Loading branch information
Showing
8 changed files
with
171 additions
and
93 deletions.
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 |
---|---|---|
@@ -1,49 +1,82 @@ | ||
FlowRouter.route '/room/:_id', | ||
name: 'room' | ||
openRoom = (type, name) -> | ||
Session.set 'openedRoom', null | ||
|
||
BlazeLayout.render 'main', {center: 'loading'} | ||
|
||
Meteor.defer -> | ||
Tracker.autorun (c) -> | ||
if RoomManager.open(type + name).ready() isnt true | ||
return | ||
|
||
c.stop() | ||
|
||
query = | ||
t: type | ||
name: name | ||
|
||
if type is 'd' | ||
delete query.name | ||
query.usernames = | ||
$all: [name, Meteor.user().username] | ||
|
||
room = ChatRoom.findOne(query) | ||
if not room? | ||
FlowRouter.go 'home' | ||
return | ||
|
||
mainNode = document.querySelector('.main-content') | ||
if mainNode? | ||
for child in mainNode.children | ||
mainNode.removeChild child if child? | ||
roomDom = RoomManager.getDomOfRoom(type + name, room._id) | ||
mainNode.appendChild roomDom | ||
if roomDom.classList.contains('room-container') | ||
roomDom.querySelector('.messages-box > .wrapper').scrollTop = roomDom.oldScrollTop | ||
|
||
Session.set 'openedRoom', room._id | ||
|
||
Session.set 'editRoomTitle', false | ||
Meteor.call 'readMessages', room._id if Meteor.userId()? | ||
# KonchatNotification.removeRoomNotification(params._id) | ||
|
||
if Meteor.Device.isDesktop() | ||
setTimeout -> | ||
$('.message-form .input-message').focus() | ||
, 100 | ||
|
||
|
||
roomExit = -> | ||
mainNode = document.querySelector('.main-content') | ||
if mainNode? | ||
for child in mainNode.children | ||
if child? | ||
if child.classList.contains('room-container') | ||
child.oldScrollTop = child.querySelector('.messages-box > .wrapper').scrollTop | ||
mainNode.removeChild child | ||
|
||
|
||
FlowRouter.route '/channel/:name', | ||
name: 'channel' | ||
|
||
action: (params, queryParams) -> | ||
Session.set 'openedRoom', null | ||
openRoom 'c', params.name | ||
|
||
BlazeLayout.render 'main', {center: 'loading'} | ||
triggersExit: [roomExit] | ||
|
||
Meteor.defer -> | ||
Tracker.autorun (c) -> | ||
if RoomManager.open(params._id).ready() isnt true | ||
return | ||
|
||
c.stop() | ||
FlowRouter.route '/group/:name', | ||
name: 'group' | ||
|
||
if not ChatRoom.find(params._id).count() | ||
FlowRouter.go 'home' | ||
return | ||
action: (params, queryParams) -> | ||
openRoom 'p', params.name | ||
|
||
mainNode = document.querySelector('.main-content') | ||
if mainNode? | ||
for child in mainNode.children | ||
mainNode.removeChild child if child? | ||
room = RoomManager.getDomOfRoom(params._id) | ||
mainNode.appendChild room | ||
if room.classList.contains('room-container') | ||
room.querySelector('.messages-box > .wrapper').scrollTop = room.oldScrollTop | ||
triggersExit: [roomExit] | ||
|
||
Session.set 'openedRoom', params._id | ||
|
||
Session.set 'editRoomTitle', false | ||
Meteor.call 'readMessages', params._id if Meteor.userId()? | ||
# KonchatNotification.removeRoomNotification(params._id) | ||
FlowRouter.route '/direct/:username', | ||
name: 'direct' | ||
|
||
if Meteor.Device.isDesktop() | ||
setTimeout -> | ||
$('.message-form .input-message').focus() | ||
, 100 | ||
action: (params, queryParams) -> | ||
openRoom 'd', params.username | ||
|
||
triggersExit: [ | ||
-> | ||
mainNode = document.querySelector('.main-content') | ||
if mainNode? | ||
for child in mainNode.children | ||
if child? | ||
if child.classList.contains('room-container') | ||
child.oldScrollTop = child.querySelector('.messages-box > .wrapper').scrollTop | ||
mainNode.removeChild child | ||
] | ||
triggersExit: [roomExit] |
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
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
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