fix(channels): sync preserve locally cleared dialogs
This commit is contained in:
parent
e22fac1c3f
commit
73cf6a8184
50 changed files with 1525 additions and 327 deletions
|
|
@ -55,11 +55,23 @@ func tgUpdatesDifference(viewerUserID int64, diff domain.UpdateDifference) tg.Up
|
|||
if nudge.ChannelID == 0 {
|
||||
continue
|
||||
}
|
||||
update := &tg.UpdateChannelTooLong{ChannelID: nudge.ChannelID}
|
||||
if nudge.Pts > 0 {
|
||||
update.SetPts(nudge.Pts)
|
||||
if nudge.AvailableMinID > 0 {
|
||||
out.OtherUpdates = append(out.OtherUpdates, &tg.UpdateChannelAvailableMessages{
|
||||
ChannelID: nudge.ChannelID,
|
||||
AvailableMinID: nudge.AvailableMinID,
|
||||
})
|
||||
}
|
||||
// Preserve compatibility for older domain callers that only supplied
|
||||
// Pts: a nudge without an owner-local boundary is a shared channel
|
||||
// update nudge. New store results set ChannelUpdatesDirty explicitly so
|
||||
// a channel can carry both absolute clear and too-long updates.
|
||||
if nudge.ChannelUpdatesDirty || nudge.AvailableMinID == 0 {
|
||||
update := &tg.UpdateChannelTooLong{ChannelID: nudge.ChannelID}
|
||||
if nudge.Pts > 0 {
|
||||
update.SetPts(nudge.Pts)
|
||||
}
|
||||
out.OtherUpdates = append(out.OtherUpdates, update)
|
||||
}
|
||||
out.OtherUpdates = append(out.OtherUpdates, update)
|
||||
if nudge.Channel != nil && nudge.Channel.Channel.ID != 0 {
|
||||
addChannelNudgeChat(out, seenChats, tgChannelChatForView(viewerUserID, *nudge.Channel))
|
||||
}
|
||||
|
|
@ -110,7 +122,7 @@ func tgChannelDifference(viewerUserID int64, diff domain.ChannelDifference) tg.U
|
|||
Users: tgUsersForViewer(viewerUserID, diff.Users),
|
||||
}
|
||||
}
|
||||
if len(diff.Events) == 0 && len(diff.NewMessages) == 0 && len(diff.OtherUpdates) == 0 {
|
||||
if len(diff.Events) == 0 && len(diff.NewMessages) == 0 && len(diff.OtherUpdates) == 0 && diff.AvailableMinID == 0 {
|
||||
return &tg.UpdatesChannelDifferenceEmpty{
|
||||
Final: diff.Final,
|
||||
Pts: diff.Pts,
|
||||
|
|
@ -136,6 +148,12 @@ func tgChannelDifference(viewerUserID int64, diff domain.ChannelDifference) tg.U
|
|||
updates = append(updates, update)
|
||||
}
|
||||
}
|
||||
if diff.AvailableMinID > 0 {
|
||||
updates = append(updates, &tg.UpdateChannelAvailableMessages{
|
||||
ChannelID: diff.Channel.ID,
|
||||
AvailableMinID: diff.AvailableMinID,
|
||||
})
|
||||
}
|
||||
chats := tgChannelDifferenceChats(viewerUserID, diff)
|
||||
users := tgUsersForViewer(viewerUserID, diff.Users)
|
||||
return &tg.UpdatesChannelDifference{
|
||||
|
|
@ -483,14 +501,6 @@ func tgOtherUpdateFromEvent(event domain.UpdateEvent) tg.UpdateClass {
|
|||
Pts: event.Pts,
|
||||
PtsCount: event.PtsCount,
|
||||
}
|
||||
case domain.UpdateEventChannelAvailable:
|
||||
if event.Peer.Type != domain.PeerTypeChannel || event.Peer.ID == 0 || event.MaxID <= 0 {
|
||||
return nil
|
||||
}
|
||||
return &tg.UpdateChannelAvailableMessages{
|
||||
ChannelID: event.Peer.ID,
|
||||
AvailableMinID: event.MaxID,
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue