history: add arrow directions
parent
e2f0ad09da
commit
0287a721c0
21
src/types.jl
21
src/types.jl
|
@ -12,6 +12,11 @@ struct MatrixUser
|
||||||
deviceid::String
|
deviceid::String
|
||||||
end
|
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
|
import Base.show
|
||||||
function Base.show(io::IO, n::MatrixServer)
|
function Base.show(io::IO, n::MatrixServer)
|
||||||
print(io, string("(matrix) ", n.instance))
|
print(io, string("(matrix) ", n.instance))
|
||||||
|
@ -43,7 +48,19 @@ struct MatrixMsg
|
||||||
end
|
end
|
||||||
|
|
||||||
using Dates
|
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 +
|
d = Dates.epochms2datetime(m.timestamp +
|
||||||
Dates.datetime2epochms(Dates.unix2datetime(0)))
|
Dates.datetime2epochms(Dates.unix2datetime(0)))
|
||||||
dtfmt = if Dates.Hour(now()) - Dates.Hour(d) < Dates.Hour(24)
|
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))
|
string(day(d), " ", Dates.monthabbr(d))
|
||||||
end
|
end
|
||||||
|
|
||||||
print(io, string("[", dtfmt, "] ", m.sender, " »»» ", m.body))
|
print(io, string("[", dtfmt, "] ", m.sender, direction, m.body))
|
||||||
nothing
|
nothing
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue