feat: show real sync date in "Fetch more messages" button

This commit is contained in:
Richard Ramos 2021-12-01 16:20:06 -04:00
parent f0ee4bb402
commit a85ee8581a
4 changed files with 30 additions and 7 deletions

View File

@ -22,6 +22,8 @@ type
Description = UserRole + 12
CategoryId = UserRole + 13
Position = UserRole + 14
SyncedFrom = UserRole + 15
SyncedTo = UserRole + 16
QtObject:
type
@ -69,6 +71,8 @@ QtObject:
of ChannelsRoles.CategoryId: result = newQVariant(chatItem.categoryId)
of ChannelsRoles.Description: result = newQVariant(chatItem.description)
of ChannelsRoles.Position: result = newQVariant(chatItem.position)
of ChannelsRoles.SyncedFrom: result = newQVariant($chatItem.syncedFrom)
of ChannelsRoles.SyncedTo: result = newQVariant($chatItem.syncedTo)
method roleNames(self: ChannelsList): Table[int, string] =
{
@ -85,7 +89,9 @@ QtObject:
ChannelsRoles.Id.int: "id",
ChannelsRoles.Description.int: "description",
ChannelsRoles.CategoryId.int: "categoryId",
ChannelsRoles.Position.int: "position"
ChannelsRoles.Position.int: "position",
ChannelsRoles.SyncedFrom.int: "syncedFrom",
ChannelsRoles.SyncedTo.int: "syncedTo",
}.toTable
proc sortChats(x, y: Chat): int =
@ -186,7 +192,9 @@ QtObject:
ChannelsRoles.Color.int,
ChannelsRoles.MentionsCount.int,
ChannelsRoles.Muted.int,
ChannelsRoles.Position.int])
ChannelsRoles.Position.int,
ChannelsRoles.SyncedFrom.int,
ChannelsRoles.SyncedTo.int])
proc clearUnreadMessages*(self: ChannelsList, channelId: string) =
let idx = self.chats.findIndexById(channelId)

View File

@ -26,6 +26,8 @@ QtObject:
result.chatMembers = newChatMembersView(status)
result.setup
proc chatItemChanged*(self: ChatItemView) {.signal.}
proc membershipChanged*(self: ChatItemView) {.signal.}
proc setChatItem*(self: ChatItemView, chatItem: Chat) =
@ -35,6 +37,7 @@ QtObject:
self.chatItem = chatItem
self.chatMembers.setMembers(chatItem.members)
self.membershipChanged()
self.chatItemChanged()
proc id*(self: ChatItemView): string {.slot.} = result = ?.self.chatItem.id
@ -205,3 +208,15 @@ QtObject:
self.chatItem.muted = false
self.status.chat.unmuteChat(self.chatItem)
self.mutedChanged()
proc syncedFrom*(self: ChatItemView): string {.slot.} = result = $(?.self.chatItem.syncedFrom)
proc syncedTo*(self: ChatItemView): string {.slot.} = result = $(?.self.chatItem.syncedTo)
QtProperty[string] syncedFrom:
read = syncedFrom
notify = chatItemChanged
QtProperty[string] syncedTo:
read = syncedTo
notify = chatItemChanged

View File

@ -10,8 +10,6 @@ Item {
height: childrenRect.height + Style.current.smallPadding * 2
anchors.left: parent.left
anchors.right: parent.right
// property int nextMessageIndex
// property string nextMsgTimestamp
signal clicked()
signal timerTriggered()
Timer {
@ -72,7 +70,11 @@ Item {
horizontalAlignment: Text.AlignHCenter
color: Style.current.secondaryText
//% "before %1"
text: qsTrId("before--1").arg((nextMessageIndex > -1 ? new Date(nextMsgTimestamp * 1) : new Date()).toLocaleString(Qt.locale(localAppSettings.locale)))
text: {
let d = chatsModel.channelView.activeChannel.syncedTo == 0 ? new Date() : new Date(chatsModel.channelView.activeChannel.syncedTo * 1000)
return qsTrId("before--1").arg(d.toLocaleString(Qt.locale(localAppSettings.locale)))
}
}
Separator {
anchors.top: fetchDate.bottom

View File

@ -260,8 +260,6 @@ Column {
Component {
id: fetchMoreMessagesButtonComponent
FetchMoreMessagesButton {
// nextMessageIndex: root.messageStore.nextMessageIndex
// nextMsgTimestamp: root.messageStore.nextMsgTimestamp
onClicked: {
root.chatsModel.messageView.hideLoadingIndicator();
}