forked from matrix/element-web
Merge branch 'develop' into kegan/controller-merging4
This commit is contained in:
commit
b89bd35cad
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2015 OpenMarket Ltd
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
avatarUrlForMember: function(member, width, height, resizeMethod) {
|
|
||||||
var url = member.getAvatarUrl(
|
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
resizeMethod
|
|
||||||
);
|
|
||||||
if (!url) {
|
|
||||||
// member can be null here currently since on invites, the JS SDK
|
|
||||||
// does not have enough info to build a RoomMember object for
|
|
||||||
// the inviter.
|
|
||||||
url = this.defaultAvatarUrlForString(member ? member.userId : '');
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
},
|
|
||||||
|
|
||||||
defaultAvatarUrlForString: function(s) {
|
|
||||||
var total = 0;
|
|
||||||
for (var i = 0; i < s.length; ++i) {
|
|
||||||
total += s.charCodeAt(i);
|
|
||||||
}
|
|
||||||
switch (total % 3) {
|
|
||||||
case 0:
|
|
||||||
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAIAAAADnC86AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNrszQENADAIACB9QjNbxSKP4eagAFnTseHFErFYLBaLxWKxWCwWi8Vi8cX4CzAABSwCRWJw31gAAAAASUVORK5CYII=";
|
|
||||||
case 1:
|
|
||||||
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAIAAAADnC86AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNrszQENADAIACB9chOaxgCP4eagAFk9seHFErFYLBaLxWKxWCwWi8Vi8cX4CzAAtKMCks/JG8MAAAAASUVORK5CYII=";
|
|
||||||
case 2:
|
|
||||||
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAIAAAADnC86AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNrszQENADAIACB9YzNayQCP4eagADldseHFErFYLBaLxWKxWCwWi8Vi8cX4CzAAyiACeHwPiu4AAAAASUVORK5CYII=";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -455,6 +455,7 @@ module.exports = {
|
||||||
event_context: {
|
event_context: {
|
||||||
before_limit: 1,
|
before_limit: 1,
|
||||||
after_limit: 1,
|
after_limit: 1,
|
||||||
|
include_profile: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,7 +500,7 @@ module.exports = {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
var EventTile = sdk.getComponent('messages.Event');
|
var EventTile = sdk.getComponent('rooms.EventTile');
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this.state.searchResults &&
|
if (this.state.searchResults &&
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Open Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src: local('Open Sans'), local('OpenSans'), url(u-WUoqrET9fUeobQW7jkRaCWcynf_cDxXwCLxiixG1c.ttf) format('truetype');
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Open Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 700;
|
||||||
|
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(k3k702ZOKiLJc3WVjuplzNqQynqKV_9Plp7mupa0S4g.ttf) format('truetype');
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
|
@ -45,22 +45,21 @@ skin['elements.EditableText'] = require('matrix-react-sdk/lib/components/views/e
|
||||||
skin['elements.ProgressBar'] = require('matrix-react-sdk/lib/components/views/elements/ProgressBar');
|
skin['elements.ProgressBar'] = require('matrix-react-sdk/lib/components/views/elements/ProgressBar');
|
||||||
skin['elements.UserSelector'] = require('matrix-react-sdk/lib/components/views/elements/UserSelector');
|
skin['elements.UserSelector'] = require('matrix-react-sdk/lib/components/views/elements/UserSelector');
|
||||||
|
|
||||||
skin['messages.MessageComposer'] = require('matrix-react-sdk/lib/components/views/messages/MessageComposer');
|
|
||||||
skin['messages.TextualEvent'] = require('matrix-react-sdk/lib/components/views/messages/TextualEvent');
|
skin['messages.TextualEvent'] = require('matrix-react-sdk/lib/components/views/messages/TextualEvent');
|
||||||
skin['messages.MRoomMemberEvent'] = require('matrix-react-sdk/lib/components/views/messages/MRoomMemberEvent');
|
skin['messages.MessageEvent'] = require('matrix-react-sdk/lib/components/views/messages/MessageEvent');
|
||||||
skin['messages.Event'] = require('matrix-react-sdk/lib/components/views/messages/Event');
|
skin['messages.MFileBody'] = require('matrix-react-sdk/lib/components/views/messages/MFileBody');
|
||||||
skin['messages.Message'] = require('matrix-react-sdk/lib/components/views/messages/Message');
|
skin['messages.MImageBody'] = require('matrix-react-sdk/lib/components/views/messages/MImageBody');
|
||||||
skin['messages.MFileMessage'] = require('matrix-react-sdk/lib/components/views/messages/MFileMessage');
|
skin['messages.MVideoBody'] = require('matrix-react-sdk/lib/components/views/messages/MVideoBody');
|
||||||
skin['messages.MImageMessage'] = require('matrix-react-sdk/lib/components/views/messages/MImageMessage');
|
skin['messages.TextualBody'] = require('matrix-react-sdk/lib/components/views/messages/TextualBody');
|
||||||
skin['messages.MVideoMessage'] = require('matrix-react-sdk/lib/components/views/messages/MVideoMessage');
|
skin['messages.UnknownBody'] = require('matrix-react-sdk/lib/components/views/messages/UnknownBody');
|
||||||
skin['messages.TextualMessage'] = require('matrix-react-sdk/lib/components/views/messages/TextualMessage');
|
|
||||||
skin['messages.UnknownMessage'] = require('matrix-react-sdk/lib/components/views/messages/UnknownMessage');
|
|
||||||
|
|
||||||
skin['rooms.MemberInfo'] = require('matrix-react-sdk/lib/components/views/rooms/MemberInfo');
|
skin['rooms.MemberInfo'] = require('matrix-react-sdk/lib/components/views/rooms/MemberInfo');
|
||||||
skin['rooms.RoomHeader'] = require('matrix-react-sdk/lib/components/views/rooms/RoomHeader');
|
skin['rooms.RoomHeader'] = require('matrix-react-sdk/lib/components/views/rooms/RoomHeader');
|
||||||
skin['rooms.RoomSettings'] = require('matrix-react-sdk/lib/components/views/rooms/RoomSettings');
|
skin['rooms.RoomSettings'] = require('matrix-react-sdk/lib/components/views/rooms/RoomSettings');
|
||||||
skin['rooms.MemberTile'] = require('matrix-react-sdk/lib/components/views/rooms/MemberTile');
|
skin['rooms.MemberTile'] = require('matrix-react-sdk/lib/components/views/rooms/MemberTile');
|
||||||
skin['rooms.MemberList'] = require('matrix-react-sdk/lib/components/views/rooms/MemberList');
|
skin['rooms.MemberList'] = require('matrix-react-sdk/lib/components/views/rooms/MemberList');
|
||||||
|
skin['rooms.MessageComposer'] = require('matrix-react-sdk/lib/components/views/rooms/MessageComposer');
|
||||||
|
skin['rooms.EventTile'] = require('matrix-react-sdk/lib/components/views/rooms/EventTile');
|
||||||
|
|
||||||
skin['create_room.CreateRoomButton'] = require('matrix-react-sdk/lib/components/views/create_room/CreateRoomButton');
|
skin['create_room.CreateRoomButton'] = require('matrix-react-sdk/lib/components/views/create_room/CreateRoomButton');
|
||||||
skin['create_room.Presets'] = require('matrix-react-sdk/lib/components/views/create_room/Presets');
|
skin['create_room.Presets'] = require('matrix-react-sdk/lib/components/views/create_room/Presets');
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
Copyright 2015 OpenMarket Ltd
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var NotifierController = require('matrix-react-sdk/lib/controllers/organisms/Notifier')
|
||||||
|
|
||||||
|
var TextForEvent = require('matrix-react-sdk/lib/TextForEvent');
|
||||||
|
var extend = require('matrix-react-sdk/lib/extend');
|
||||||
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
||||||
|
var Avatar = require('matrix-react-sdk/lib/Avatar');
|
||||||
|
|
||||||
|
var NotifierView = {
|
||||||
|
notificationMessageForEvent: function(ev) {
|
||||||
|
return TextForEvent.textForEvent(ev);
|
||||||
|
},
|
||||||
|
|
||||||
|
displayNotification: function(ev, room) {
|
||||||
|
if (!global.Notification || global.Notification.permission != 'granted') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (global.document.hasFocus()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var msg = this.notificationMessageForEvent(ev);
|
||||||
|
if (!msg) return;
|
||||||
|
|
||||||
|
var title;
|
||||||
|
if (!ev.sender || room.name == ev.sender.name) {
|
||||||
|
title = room.name;
|
||||||
|
// notificationMessageForEvent includes sender,
|
||||||
|
// but we already have the sender here
|
||||||
|
if (ev.getContent().body) msg = ev.getContent().body;
|
||||||
|
} else if (ev.getType() == 'm.room.member') {
|
||||||
|
// context is all in the message here, we don't need
|
||||||
|
// to display sender info
|
||||||
|
title = room.name;
|
||||||
|
} else if (ev.sender) {
|
||||||
|
title = ev.sender.name + " (" + room.name + ")";
|
||||||
|
// notificationMessageForEvent includes sender,
|
||||||
|
// but we've just out sender in the title
|
||||||
|
if (ev.getContent().body) msg = ev.getContent().body;
|
||||||
|
}
|
||||||
|
|
||||||
|
var avatarUrl = ev.sender ? Avatar.avatarUrlForMember(
|
||||||
|
ev.sender, 40, 40, 'crop'
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
var notification = new global.Notification(
|
||||||
|
title,
|
||||||
|
{
|
||||||
|
"body": msg,
|
||||||
|
"icon": avatarUrl,
|
||||||
|
"tag": "vector"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
notification.onclick = function() {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_room',
|
||||||
|
room_id: room.roomId
|
||||||
|
});
|
||||||
|
global.focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
/*var audioClip;
|
||||||
|
|
||||||
|
if (audioNotification) {
|
||||||
|
audioClip = playAudio(audioNotification);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
global.setTimeout(function() {
|
||||||
|
notification.close();
|
||||||
|
}, 5 * 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var NotifierClass = function() {};
|
||||||
|
extend(NotifierClass.prototype, NotifierController);
|
||||||
|
extend(NotifierClass.prototype, NotifierView);
|
||||||
|
|
||||||
|
module.exports = new NotifierClass();
|
||||||
|
|
|
@ -109,7 +109,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
var RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
||||||
var MessageComposer = sdk.getComponent('messages.MessageComposer');
|
var MessageComposer = sdk.getComponent('rooms.MessageComposer');
|
||||||
var CallView = sdk.getComponent("voip.CallView");
|
var CallView = sdk.getComponent("voip.CallView");
|
||||||
var RoomSettings = sdk.getComponent("rooms.RoomSettings");
|
var RoomSettings = sdk.getComponent("rooms.RoomSettings");
|
||||||
var SearchBar = sdk.getComponent("molecules.SearchBar");
|
var SearchBar = sdk.getComponent("molecules.SearchBar");
|
||||||
|
|
Loading…
Reference in New Issue