Skip to content

Commit

Permalink
Fix #4235 and improve bars layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Sep 14, 2016
1 parent 4b3d3e4 commit 1e83b4d
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 70 deletions.
3 changes: 3 additions & 0 deletions packages/rocketchat-cors/cors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ WebApp.rawConnectHandlers.use (req, res, next) ->
if req.headers['content-type'] not in ['', undefined]
return next()

if req.url.indexOf('/ufs/') is 0
return next()

buf = ''
req.setEncoding('utf8')
req.on 'data', (chunk) -> buf += chunk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* globals FileUpload, FileUploadBase, Slingshot */

FileUpload.AmazonS3 = class FileUploadAmazonS3 extends FileUploadBase {
constructor(meta, file, data) {
super(meta, file, data);
constructor(meta, file) {
super(meta, file);
this.uploader = new Slingshot.Upload('rocketchat-uploads', { rid: meta.rid });
}
start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ FileSystemStore = new UploadFS.store.Local({
});

FileUpload.FileSystem = class FileUploadFileSystem extends FileUploadBase {
constructor(meta, file, data) {
super(meta, file, data);
constructor(meta, file) {
super(meta, file);
this.handler = new UploadFS.Uploader({
store: FileSystemStore,
data: data,
data: file,
file: meta,
onError: (err) => {
var uploading = Session.get('uploading');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* globals FileUploadBase, UploadFS, FileUpload:true */
FileUpload.GridFS = class FileUploadGridFS extends FileUploadBase {
constructor(meta, file, data) {
super(meta, file, data);
constructor(meta, file) {
super(meta, file);
this.handler = new UploadFS.Uploader({
store: Meteor.fileStore,
data: data,
data: file,
file: meta,
onError: (err) => {
var uploading = Session.get('uploading');
Expand Down Expand Up @@ -38,6 +38,7 @@ FileUpload.GridFS = class FileUploadGridFS extends FileUploadBase {
}
});
}

start() {
return this.handler.start();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* globals FileUpload, fileUploadHandler:true */
/* exported fileUploadHandler */

fileUploadHandler = (meta, file, data) => {
fileUploadHandler = (meta, file) => {
var storageType = RocketChat.settings.get('FileUpload_Storage_Type');

if (FileUpload[storageType] !== undefined) {
return new FileUpload[storageType](meta, file, data);
return new FileUpload[storageType](meta, file);
}
};
2 changes: 1 addition & 1 deletion packages/rocketchat-file-upload/lib/FileUploadBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* exported FileUploadBase */

FileUploadBase = class FileUploadBase {
constructor(meta, file/*, data*/) {
constructor(meta, file) {
this.id = Random.id();
this.meta = meta;
this.file = file;
Expand Down
26 changes: 17 additions & 9 deletions packages/rocketchat-theme/assets/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -2001,23 +2001,23 @@ label.required:after {

.container-bars {
position: absolute;
top: 60px;
width: 100%;
top: 61px;
z-index: 11;
font-weight: bold;
display: flex;
flex-direction: column;
border-radius: 0 0 10px 10px;
overflow: hidden;
font-size: 1em;
left: 5px;
right: 5px;
box-shadow: 0px 1px 1px 0 rgba(0,0,0,0.2), 0 2px 10px 0 rgba(0,0,0,.16);
> div {
line-height: 24px;
line-height: 28px;
padding: 0 10px;
border-top: 1px solid;
&:last-child {
box-shadow: 0px 1px 2px rgba(0, 0, 0, .2);
}
}
font-size: 12px;
.upload-progress {
height: 24px;
height: 28px;
position: relative;
.upload-progress-progress {
position: absolute;
Expand All @@ -2040,6 +2040,11 @@ label.required:after {
cursor: pointer;
}
}
button {
float: right;
font-weight: bold;
text-transform: uppercase;
}
}
.unread-bar {
background-color: #E6F4FD;
Expand Down Expand Up @@ -4491,6 +4496,9 @@ body:not(.is-cordova) {
left: 0;
}
}
}

@media all and(max-width: 960px) {
.container-bars {
.unread-bar {
.unread-count {
Expand Down
76 changes: 32 additions & 44 deletions packages/rocketchat-ui/lib/fileUpload.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,61 +81,49 @@ readAsArrayBuffer = (file, callback) ->
if isConfirm isnt true
return

readAsArrayBuffer file.file, (data) ->
record =
name: file.name or file.file.name
size: file.file.size
type: file.file.type
rid: roomId

upload = fileUploadHandler record, file.file, data

# // Reactive method to get upload progress
Tracker.autorun (c) ->
uploading = undefined
cancel = undefined

Tracker.nonreactive ->
cancel = Session.get "uploading-cancel-#{upload.id}"
uploading = Session.get 'uploading'
record =
name: file.name or file.file.name
size: file.file.size
type: file.file.type
rid: roomId

upload = fileUploadHandler record, file.file

if cancel
return c.stop()
upload.handler.onProgress = (file, progress) ->
uploading = Session.get('uploading') or []

uploading ?= []
item = _.findWhere(uploading, {id: upload.id})

item = _.findWhere(uploading, {id: upload.id})
if not item?
item =
id: upload.id
name: upload.getFileName()

if not item?
item =
id: upload.id
name: upload.getFileName()
uploading.push item

uploading.push item
item.percentage = Math.round(progress * 100) or 0
Session.set 'uploading', uploading

item.percentage = Math.round(upload.getProgress() * 100) or 0
Session.set 'uploading', uploading
upload.start()

upload.start();
Tracker.autorun (c) ->
cancel = Session.get "uploading-cancel-#{upload.id}"
if cancel
upload.stop()
c.stop()

Tracker.autorun (c) ->
cancel = Session.get "uploading-cancel-#{upload.id}"
if cancel
upload.stop()
c.stop()
uploading = Session.get 'uploading'
if uploading?
item = _.findWhere(uploading, {id: upload.id})
if item?
item.percentage = 0
Session.set 'uploading', uploading

Meteor.setTimeout ->
uploading = Session.get 'uploading'
if uploading?
item = _.findWhere(uploading, {id: upload.id})
if item?
item.percentage = 0
Session.set 'uploading', uploading

Meteor.setTimeout ->
uploading = Session.get 'uploading'
if uploading?
item = _.findWhere(uploading, {id: upload.id})
Session.set 'uploading', _.without(uploading, item)
, 1000
Session.set 'uploading', _.without(uploading, item)
, 1000

consume()
13 changes: 7 additions & 6 deletions packages/rocketchat-ui/views/app/room.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ Template.room.onRendered ->
template = this

containerBars = $('.messages-container > .container-bars')
containerBarsOffset = containerBars.offset()

template.isAtBottom = ->
if wrapper.scrollTop >= wrapper.scrollHeight - wrapper.clientHeight
Expand Down Expand Up @@ -598,12 +597,14 @@ Template.room.onRendered ->
, 50

updateUnreadCount = _.throttle ->
firstMessageOnScreen = document.elementFromPoint(containerBarsOffset.left+1, containerBarsOffset.top+containerBars.height()+1)
if firstMessageOnScreen?.id?
firstMessage = ChatMessage.findOne firstMessageOnScreen.id
if firstMessage?
containerBarsOffset = containerBars.offset()

lastInvisibleMessageOnScreen = document.elementFromPoint(containerBarsOffset.left-1, containerBarsOffset.top+1)
if lastInvisibleMessageOnScreen?.id?
lastMessage = ChatMessage.findOne lastInvisibleMessageOnScreen.id
if lastMessage?
subscription = ChatSubscription.findOne rid: template.data._id
count = ChatMessage.find({rid: template.data._id, ts: {$lt: firstMessage.ts, $gt: subscription?.ls}}).count()
count = ChatMessage.find({rid: template.data._id, ts: {$lte: lastMessage.ts, $gt: subscription?.ls}}).count()
template.unreadCount.set count
else
template.unreadCount.set 0
Expand Down

0 comments on commit 1e83b4d

Please sign in to comment.