feat: show real sync date in "Fetch more messages" button
This commit is contained in:
parent
f0ee4bb402
commit
a85ee8581a
|
@ -22,6 +22,8 @@ type
|
||||||
Description = UserRole + 12
|
Description = UserRole + 12
|
||||||
CategoryId = UserRole + 13
|
CategoryId = UserRole + 13
|
||||||
Position = UserRole + 14
|
Position = UserRole + 14
|
||||||
|
SyncedFrom = UserRole + 15
|
||||||
|
SyncedTo = UserRole + 16
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
|
@ -69,6 +71,8 @@ QtObject:
|
||||||
of ChannelsRoles.CategoryId: result = newQVariant(chatItem.categoryId)
|
of ChannelsRoles.CategoryId: result = newQVariant(chatItem.categoryId)
|
||||||
of ChannelsRoles.Description: result = newQVariant(chatItem.description)
|
of ChannelsRoles.Description: result = newQVariant(chatItem.description)
|
||||||
of ChannelsRoles.Position: result = newQVariant(chatItem.position)
|
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] =
|
method roleNames(self: ChannelsList): Table[int, string] =
|
||||||
{
|
{
|
||||||
|
@ -85,7 +89,9 @@ QtObject:
|
||||||
ChannelsRoles.Id.int: "id",
|
ChannelsRoles.Id.int: "id",
|
||||||
ChannelsRoles.Description.int: "description",
|
ChannelsRoles.Description.int: "description",
|
||||||
ChannelsRoles.CategoryId.int: "categoryId",
|
ChannelsRoles.CategoryId.int: "categoryId",
|
||||||
ChannelsRoles.Position.int: "position"
|
ChannelsRoles.Position.int: "position",
|
||||||
|
ChannelsRoles.SyncedFrom.int: "syncedFrom",
|
||||||
|
ChannelsRoles.SyncedTo.int: "syncedTo",
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
proc sortChats(x, y: Chat): int =
|
proc sortChats(x, y: Chat): int =
|
||||||
|
@ -186,7 +192,9 @@ QtObject:
|
||||||
ChannelsRoles.Color.int,
|
ChannelsRoles.Color.int,
|
||||||
ChannelsRoles.MentionsCount.int,
|
ChannelsRoles.MentionsCount.int,
|
||||||
ChannelsRoles.Muted.int,
|
ChannelsRoles.Muted.int,
|
||||||
ChannelsRoles.Position.int])
|
ChannelsRoles.Position.int,
|
||||||
|
ChannelsRoles.SyncedFrom.int,
|
||||||
|
ChannelsRoles.SyncedTo.int])
|
||||||
|
|
||||||
proc clearUnreadMessages*(self: ChannelsList, channelId: string) =
|
proc clearUnreadMessages*(self: ChannelsList, channelId: string) =
|
||||||
let idx = self.chats.findIndexById(channelId)
|
let idx = self.chats.findIndexById(channelId)
|
||||||
|
|
|
@ -26,6 +26,8 @@ QtObject:
|
||||||
result.chatMembers = newChatMembersView(status)
|
result.chatMembers = newChatMembersView(status)
|
||||||
result.setup
|
result.setup
|
||||||
|
|
||||||
|
proc chatItemChanged*(self: ChatItemView) {.signal.}
|
||||||
|
|
||||||
proc membershipChanged*(self: ChatItemView) {.signal.}
|
proc membershipChanged*(self: ChatItemView) {.signal.}
|
||||||
|
|
||||||
proc setChatItem*(self: ChatItemView, chatItem: Chat) =
|
proc setChatItem*(self: ChatItemView, chatItem: Chat) =
|
||||||
|
@ -35,6 +37,7 @@ QtObject:
|
||||||
self.chatItem = chatItem
|
self.chatItem = chatItem
|
||||||
self.chatMembers.setMembers(chatItem.members)
|
self.chatMembers.setMembers(chatItem.members)
|
||||||
self.membershipChanged()
|
self.membershipChanged()
|
||||||
|
self.chatItemChanged()
|
||||||
|
|
||||||
proc id*(self: ChatItemView): string {.slot.} = result = ?.self.chatItem.id
|
proc id*(self: ChatItemView): string {.slot.} = result = ?.self.chatItem.id
|
||||||
|
|
||||||
|
@ -205,3 +208,15 @@ QtObject:
|
||||||
self.chatItem.muted = false
|
self.chatItem.muted = false
|
||||||
self.status.chat.unmuteChat(self.chatItem)
|
self.status.chat.unmuteChat(self.chatItem)
|
||||||
self.mutedChanged()
|
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
|
|
@ -10,8 +10,6 @@ Item {
|
||||||
height: childrenRect.height + Style.current.smallPadding * 2
|
height: childrenRect.height + Style.current.smallPadding * 2
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
// property int nextMessageIndex
|
|
||||||
// property string nextMsgTimestamp
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
signal timerTriggered()
|
signal timerTriggered()
|
||||||
Timer {
|
Timer {
|
||||||
|
@ -72,7 +70,11 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
color: Style.current.secondaryText
|
color: Style.current.secondaryText
|
||||||
//% "before %1"
|
//% "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 {
|
Separator {
|
||||||
anchors.top: fetchDate.bottom
|
anchors.top: fetchDate.bottom
|
||||||
|
|
|
@ -260,8 +260,6 @@ Column {
|
||||||
Component {
|
Component {
|
||||||
id: fetchMoreMessagesButtonComponent
|
id: fetchMoreMessagesButtonComponent
|
||||||
FetchMoreMessagesButton {
|
FetchMoreMessagesButton {
|
||||||
// nextMessageIndex: root.messageStore.nextMessageIndex
|
|
||||||
// nextMsgTimestamp: root.messageStore.nextMsgTimestamp
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.chatsModel.messageView.hideLoadingIndicator();
|
root.chatsModel.messageView.hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue