history: add arrow directions

master
Nicolò Balzarotti 2018-09-18 09:13:06 +02:00
parent e2f0ad09da
commit 0287a721c0
1 changed files with 19 additions and 2 deletions

View File

@ -12,6 +12,11 @@ struct MatrixUser
deviceid::String
end
import Base.==
==(u::MatrixUser, s::String) =
string("@", u.userid, ":", join(split(URI(u.server.instance).host, ".")[end-1:end], ".")) == s
==(s::String, u::MatrixUser) = u == s
import Base.show
function Base.show(io::IO, n::MatrixServer)
print(io, string("(matrix) ", n.instance))
@ -43,7 +48,19 @@ struct MatrixMsg
end
using Dates
function Base.show(io::IO, m::MatrixMsg)
function Base.show(io::IO, m::MatrixMsg; muser::Union{Nothing,MatrixUser} = nothing)
global user
if muser === nothing
if isdefined(MatrixChat, :user)
direction = m.sender == user ?
" ««« " : " »»» "
else
direction = " »»» "
end
else
direction = " »»» "
end
d = Dates.epochms2datetime(m.timestamp +
Dates.datetime2epochms(Dates.unix2datetime(0)))
dtfmt = if Dates.Hour(now()) - Dates.Hour(d) < Dates.Hour(24)
@ -52,6 +69,6 @@ function Base.show(io::IO, m::MatrixMsg)
string(day(d), " ", Dates.monthabbr(d))
end
print(io, string("[", dtfmt, "] ", m.sender, " »»» ", m.body))
print(io, string("[", dtfmt, "] ", m.sender, direction, m.body))
nothing
end