chat-list-notifications

This commit is contained in:
Achilles Rasquinha 2018-01-23 12:21:30 +05:30
parent 3f8bf0b5a9
commit 17d334a5ff
3 changed files with 53 additions and 29 deletions

View file

@ -448,3 +448,16 @@ a.no-decoration:active {
.chat-list .chat-list-item .chat-bubble .chat-bubble-meta > .chat-bubble-check i {
font-size: 12px;
}
.chat-list-notification {
text-align: center;
}
.chat-list-notification-content {
color: white;
background-color: #8D99A6;
display: inline-block;
/* padding: 5px; */
border-radius: 20px;
opacity: 0.5;
font-size: 10px;
padding: 5px;
}

View file

@ -139,16 +139,16 @@ frappe.datetime.datetime = class
* @example
* const datetime = new frappe.datetime.now()
*/
frappe.datetime.now = () => new frappe.datetime.datetime()
frappe.datetime.now = () => new frappe.datetime.datetime()
frappe.datetime.diff = (a, b, type) =>
frappe.datetime.equal = (a, b, type) =>
{
a = a.moment
b = b.moment
diff = a.diff(b, type)
const equal = a.isSame(b, type)
return diff
return equal
}
/**
@ -2261,32 +2261,21 @@ class extends Component
render ( )
{
const { props } = this
const { messages } = props
var messages = [ ]
for (var i = 0 ; i < this.props.messages.length ; ++i)
{
var message = this.props.messages[i]
const me = message.user === frappe.session.user
if ( i === 0 || !frappe.datetime.equal(message.creation, this.props.messages[i - 1].creation, 'day') )
messages.push({ type: "Notification", content: message.creation.format('MMMM DD') })
messages.push(message)
}
return !frappe._.is_empty(messages) ? (
h("div",{class:"chat-list list-group"},
messages.map((m, i) =>
{
const me = m.user === frappe.session.user;
let groupable = false;
if ( i !== 0 && i !== messages.length )
groupable = !me && m.room_type === "Group" && m.user === messages[i - 1].user
if ( i === 0 || frappe.datetime.diff(m.creation, messages[i - 1].creation))
{
return (
h(frappe.chat.component.ChatList.Item,
{
type: "Notification",
content: ""
})
)
}
return h(frappe.chat.component.ChatList.Item, {...m, type: type, groupable: groupable})
})
messages.map(m => h(frappe.chat.component.ChatList.Item, {...m}))
)
) : null
}
@ -2316,8 +2305,12 @@ class extends Component
return (
h("div",{class: "chat-list-item list-group-item"},
me.type === "Notification" ?
h("div","","")
props.type === "Notification" ?
h("div",{class:"chat-list-notification"},
h("div",{class:"chat-list-notification-content"},
props.content
)
)
:
h("div",{class:`${me ? "text-right" : ""}`},
!me && !props.groupable && !me ?

View file

@ -371,4 +371,22 @@
}
}
}
}
.chat-list-notification
{
text-align: center;
}
.chat-list-notification-content
{
color: white;
background-color: #8D99A6;
display: inline-block;
/* padding: 5px; */
border-radius: 20px;
opacity: 0.5;
font-size: 10px;
padding: 5px;
// background-color: white;
}