From c5e33352b0acbebfe9e91fca711c012b0864beef Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 14 Aug 2015 15:24:34 +0100 Subject: [PATCH] You can't just use React classes as normal static classes :( --- skins/base/views/organisms/Notifier.js | 7 ++++--- src/{DefaultAvatar.js => Avatar.js} | 12 ++++++++++++ src/controllers/atoms/MemberAvatar.js | 26 +++++++------------------- src/controllers/atoms/RoomAvatar.js | 7 ++----- src/controllers/organisms/RoomView.js | 5 +++-- 5 files changed, 28 insertions(+), 29 deletions(-) rename src/{DefaultAvatar.js => Avatar.js} (81%) diff --git a/skins/base/views/organisms/Notifier.js b/skins/base/views/organisms/Notifier.js index 8dcb03da8c..556d6b3a35 100644 --- a/skins/base/views/organisms/Notifier.js +++ b/skins/base/views/organisms/Notifier.js @@ -23,8 +23,7 @@ var TextForEvent = require("../../../../src/TextForEvent"); var extend = require("../../../../src/extend"); var dis = require("../../../../src/dispatcher"); -var ComponentBroker = require("../../../../src/ComponentBroker"); -var MemberAvatar = ComponentBroker.get("atoms/MemberAvatar"); +var Avatar = require("../../../../src/Avatar"); var NotifierView = { @@ -60,7 +59,9 @@ var NotifierView = { if (ev.getContent().body) msg = ev.getContent().body; } - var avatarUrlrl = MemberAvatar.avatarUrlForMember(ev.sender); + var avatarUrl = Avatar.avatarUrlForMember( + ev.sender, 40, 40, 'crop' + ); var notification = new global.Notification( title, diff --git a/src/DefaultAvatar.js b/src/Avatar.js similarity index 81% rename from src/DefaultAvatar.js rename to src/Avatar.js index 5183d33b0d..bdfc20ca80 100644 --- a/src/DefaultAvatar.js +++ b/src/Avatar.js @@ -16,7 +16,19 @@ limitations under the License. 'use strict'; +var MatrixClientPeg = require('./MatrixClientPeg'); + module.exports = { + avatarUrlForMember: function(member, width, height, resizeMethod) { + var url = MatrixClientPeg.get().getAvatarUrlForMember( + member, width, height, resizeMethod, false + ); + if (url === null) { + url = this.defaultAvatarUrlForString(member.userId); + } + return url; + }, + defaultAvatarUrlForString: function(s) { var total = 0; for (var i = 0; i < s.length; ++i) { diff --git a/src/controllers/atoms/MemberAvatar.js b/src/controllers/atoms/MemberAvatar.js index b7626abc4c..f29b3544e7 100644 --- a/src/controllers/atoms/MemberAvatar.js +++ b/src/controllers/atoms/MemberAvatar.js @@ -16,8 +16,7 @@ limitations under the License. 'use strict'; -var MatrixClientPeg = require('../../MatrixClientPeg'); -var DefaultAvatar = require('../../DefaultAvatar'); +var Avatar = require('../../Avatar'); var React = require('react'); @@ -37,23 +36,8 @@ module.exports = { } }, - // takes member as an arg so it can be used if the - // avatars are required outsode of components - // (eg. in html5 desktop notifs) - avatarUrlForMember: function(member) { - var url = MatrixClientPeg.get().getAvatarUrlForMember( - member, - this.props.width, this.props.height, this.props.resizeMethod, - false - ); - if (url === null) { - url = this.defaultAvatarUrl(member); - } - return url; - }, - defaultAvatarUrl: function(member) { - return DefaultAvatar.defaultAvatarUrlForString( + return Avatar.defaultAvatarUrlForString( member.userId ); }, @@ -70,7 +54,11 @@ module.exports = { getInitialState: function() { return { - imageUrl: this.avatarUrlForMember(this.props.member) + imageUrl: Avatar.avatarUrlForMember( + this.props.member, + this.props.width, this.props.height, + this.props.resizeMethod + ) }; } }; diff --git a/src/controllers/atoms/RoomAvatar.js b/src/controllers/atoms/RoomAvatar.js index 902153e035..1504a77613 100644 --- a/src/controllers/atoms/RoomAvatar.js +++ b/src/controllers/atoms/RoomAvatar.js @@ -17,7 +17,7 @@ limitations under the License. 'use strict'; var MatrixClientPeg = require('../../MatrixClientPeg'); -var DefaultAvatar = require('../../DefaultAvatar'); +var Avatar = require('../../Avatar'); module.exports = { getDefaultProps: function() { @@ -28,9 +28,6 @@ module.exports = { } }, - // takes member as an arg so it can be used if the - // avatars are required outsode of components - // (eg. in html5 desktop notifs, although this is not) avatarUrlForRoom: function(room) { var url = MatrixClientPeg.get().getAvatarUrlForRoom( room, @@ -44,7 +41,7 @@ module.exports = { }, defaultAvatarUrl: function(room) { - return DefaultAvatar.defaultAvatarUrlForString( + return Avatar.defaultAvatarUrlForString( this.props.room.roomId ); }, diff --git a/src/controllers/organisms/RoomView.js b/src/controllers/organisms/RoomView.js index d3feff69f6..3e3d6f0641 100644 --- a/src/controllers/organisms/RoomView.js +++ b/src/controllers/organisms/RoomView.js @@ -179,9 +179,10 @@ module.exports = { messageWrapper.addEventListener('dragleave', this.onDragLeaveOrEnd); messageWrapper.addEventListener('dragend', this.onDragLeaveOrEnd); - messageWrapper.scrollTop = messageWrapper.scrollHeight; + //messageWrapper.scrollTop = messageWrapper.scrollHeight; - this.fillSpace(); + setTimeout(this.fillSpace, 50); + //this.fillSpace(); } },