Adding last activity informations.
This commit is contained in:
parent
b65d6ddde7
commit
b64d9730d0
@ -63,7 +63,17 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
|||||||
container.textContent = json.error
|
container.textContent = json.error
|
||||||
container.classList.add('peertube-plugin-livechat-error')
|
container.classList.add('peertube-plugin-livechat-error')
|
||||||
} else {
|
} else {
|
||||||
const rooms = json.rooms.sort((a, b) => a.name.localeCompare(b.name))
|
const rooms = json.rooms.sort((a, b) => {
|
||||||
|
const timestampA = a.lasttimestamp ?? 0
|
||||||
|
const timestampB = b.lasttimestamp ?? 0
|
||||||
|
if (timestampA === timestampB) {
|
||||||
|
return a.name.localeCompare(b.name)
|
||||||
|
} else if (timestampA < timestampB) {
|
||||||
|
return 1
|
||||||
|
} else {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
container.textContent = ''
|
container.textContent = ''
|
||||||
const table = document.createElement('table')
|
const table = document.createElement('table')
|
||||||
@ -74,8 +84,10 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
|||||||
RoomName: 'Room name',
|
RoomName: 'Room name',
|
||||||
RoomDescription: 'Room description',
|
RoomDescription: 'Room description',
|
||||||
NotFound: 'Not found',
|
NotFound: 'Not found',
|
||||||
Video: 'Video'
|
Video: 'Video',
|
||||||
|
LastActivity: 'Last activity'
|
||||||
}
|
}
|
||||||
|
|
||||||
const titleLineEl = document.createElement('tr')
|
const titleLineEl = document.createElement('tr')
|
||||||
const titleNameEl = document.createElement('th')
|
const titleNameEl = document.createElement('th')
|
||||||
titleNameEl.textContent = labels.RoomName
|
titleNameEl.textContent = labels.RoomName
|
||||||
@ -83,9 +95,12 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
|||||||
titleDescriptionEl.textContent = labels.RoomDescription
|
titleDescriptionEl.textContent = labels.RoomDescription
|
||||||
const titleVideoEl = document.createElement('th')
|
const titleVideoEl = document.createElement('th')
|
||||||
titleVideoEl.textContent = labels.Video
|
titleVideoEl.textContent = labels.Video
|
||||||
|
const titleLastActivityEl = document.createElement('th')
|
||||||
|
titleLastActivityEl.textContent = labels.LastActivity
|
||||||
titleLineEl.append(titleNameEl)
|
titleLineEl.append(titleNameEl)
|
||||||
titleLineEl.append(titleDescriptionEl)
|
titleLineEl.append(titleDescriptionEl)
|
||||||
titleLineEl.append(titleVideoEl)
|
titleLineEl.append(titleVideoEl)
|
||||||
|
titleLineEl.append(titleLastActivityEl)
|
||||||
table.append(titleLineEl)
|
table.append(titleLineEl)
|
||||||
rooms.forEach(room => {
|
rooms.forEach(room => {
|
||||||
const uuid = room.localpart
|
const uuid = room.localpart
|
||||||
@ -98,10 +113,16 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
|||||||
const descriptionEl = document.createElement('td')
|
const descriptionEl = document.createElement('td')
|
||||||
descriptionEl.textContent = room.description
|
descriptionEl.textContent = room.description
|
||||||
const videoEl = document.createElement('td')
|
const videoEl = document.createElement('td')
|
||||||
|
const lastActivityEl = document.createElement('td')
|
||||||
|
if (room.lasttimestamp && (typeof room.lasttimestamp === 'number')) {
|
||||||
|
const date = new Date(room.lasttimestamp * 1000)
|
||||||
|
lastActivityEl.textContent = date.toLocaleDateString() + ' ' + date.toLocaleTimeString()
|
||||||
|
}
|
||||||
nameEl.append(aEl)
|
nameEl.append(aEl)
|
||||||
lineEl.append(nameEl)
|
lineEl.append(nameEl)
|
||||||
lineEl.append(descriptionEl)
|
lineEl.append(descriptionEl)
|
||||||
lineEl.append(videoEl)
|
lineEl.append(videoEl)
|
||||||
|
lineEl.append(lastActivityEl)
|
||||||
table.append(lineEl)
|
table.append(lineEl)
|
||||||
|
|
||||||
if (/^[a-zA-A0-9-]+$/.test(uuid)) {
|
if (/^[a-zA-A0-9-]+$/.test(uuid)) {
|
||||||
|
@ -36,12 +36,18 @@ local function list_rooms(event)
|
|||||||
local rooms_json = array();
|
local rooms_json = array();
|
||||||
for room in all_rooms() do
|
for room in all_rooms() do
|
||||||
local localpart = jid_split(room.jid);
|
local localpart = jid_split(room.jid);
|
||||||
|
local history = room._history;
|
||||||
|
local lasttimestamp;
|
||||||
|
if history ~= nil and #history > 0 then
|
||||||
|
lasttimestamp = history[#history].timestamp;
|
||||||
|
end
|
||||||
rooms_json:push({
|
rooms_json:push({
|
||||||
jid = room.jid;
|
jid = room.jid;
|
||||||
localpart = localpart;
|
localpart = localpart;
|
||||||
name = room:get_name() or localpart;
|
name = room:get_name() or localpart;
|
||||||
lang = room.get_language and room:get_language();
|
lang = room.get_language and room:get_language();
|
||||||
description = room:get_description();
|
description = room:get_description();
|
||||||
|
lasttimestamp = lasttimestamp;
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ interface ProsodyListRoomsResultSuccess {
|
|||||||
name: string
|
name: string
|
||||||
lang: string
|
lang: string
|
||||||
description: string
|
description: string
|
||||||
|
lasttimestamp?: number
|
||||||
}>
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user