mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
fix(app): never lower the read-state unread watermark (#2704)
This commit is contained in:
@@ -118,55 +118,32 @@ describe('ReadStates unread invariant', () => {
|
||||
expect(ReadStates.hasUnread(channelId)).toBe(true);
|
||||
});
|
||||
|
||||
it('still lets its own probe lower a watermark a passive update raised', () => {
|
||||
it('never lowers the watermark when an after page comes back empty', () => {
|
||||
const {channelId} = seedReadChannel();
|
||||
loadedMessages.push({id: ID.ack, author: {id: 'someone'}});
|
||||
ReadStates.handlePassiveLastMessageUpdates({[channelId]: ID.newer}, 'guild-1');
|
||||
ReadStates.handleLoadMessages({channelId, isAfter: true, messages: [], tailProbeWatermarkId: ID.newer});
|
||||
expect(ReadStates.lastMessageId(channelId)).toBe(ID.ack);
|
||||
expect(ReadStates.hasUnread(channelId)).toBe(false);
|
||||
ReadStates.handleLoadMessages({channelId, isAfter: true, messages: []});
|
||||
expect(ReadStates.lastMessageId(channelId)).toBe(ID.newer);
|
||||
expect(ReadStates.hasUnread(channelId)).toBe(true);
|
||||
});
|
||||
|
||||
it('lowers a watermark its own probe finds nothing behind', () => {
|
||||
const {channelId, state} = seedReadChannel();
|
||||
state.lastMessageId = ID.newer;
|
||||
loadedMessages.push({id: ID.ack, author: {id: 'someone'}});
|
||||
ReadStates.handleLoadMessages({channelId, isAfter: true, messages: [], tailProbeWatermarkId: ID.newer});
|
||||
expect(ReadStates.lastMessageId(channelId)).toBe(ID.ack);
|
||||
expect(ReadStates.hasUnread(channelId)).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps a watermark that is ahead when an ordinary after page comes back empty', () => {
|
||||
it('keeps a watermark that points at a message no longer in the channel', () => {
|
||||
const {channelId, state} = seedReadChannel();
|
||||
state.lastMessageId = ID.newer;
|
||||
loadedMessages.push({id: ID.ack, author: {id: 'someone'}});
|
||||
ReadStates.handleLoadMessages({channelId, isAfter: true, messages: []});
|
||||
expect(ReadStates.lastMessageId(channelId)).toBe(ID.newer);
|
||||
expect(ReadStates.hasUnread(channelId)).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps a watermark that advanced while its own probe was in flight', () => {
|
||||
it('acks up to the watermark so a deleted newest message cannot keep the channel unread', () => {
|
||||
const {channelId, state} = seedReadChannel();
|
||||
state.lastMessageId = ID.newer;
|
||||
loadedMessages.push({id: ID.ack, author: {id: 'someone'}});
|
||||
ReadStates.handleLoadMessages({channelId, isAfter: true, messages: [], tailProbeWatermarkId: ID.ack});
|
||||
expect(ReadStates.lastMessageId(channelId)).toBe(ID.newer);
|
||||
});
|
||||
|
||||
it('keeps a watermark that is ahead when the page was not an after page', () => {
|
||||
const {channelId, state} = seedReadChannel();
|
||||
state.lastMessageId = ID.newer;
|
||||
loadedMessages.push({id: ID.ack, author: {id: 'someone'}});
|
||||
ReadStates.handleLoadMessages({channelId, messages: [], tailProbeWatermarkId: ID.newer});
|
||||
expect(ReadStates.lastMessageId(channelId)).toBe(ID.newer);
|
||||
});
|
||||
|
||||
it('keeps a watermark that is ahead when the window is not at the live edge', () => {
|
||||
const {channelId, state} = seedReadChannel();
|
||||
hasNewestMessages = false;
|
||||
state.lastMessageId = ID.newer;
|
||||
loadedMessages.push({id: ID.ack, author: {id: 'someone'}});
|
||||
ReadStates.handleLoadMessages({channelId, isAfter: true, messages: [], tailProbeWatermarkId: ID.newer});
|
||||
expect(ReadStates.lastMessageId(channelId)).toBe(ID.newer);
|
||||
ReadStates.handleLoadMessages({channelId, isAfter: true, messages: []});
|
||||
ReadStates.handleChannelAckWithStickyUnread({channelId});
|
||||
expect(ReadStates.ackMessageId(channelId)).toBe(ID.newer);
|
||||
expect(ReadStates.hasUnread(channelId)).toBe(false);
|
||||
});
|
||||
|
||||
it('anchors the divider when a window is loaded whose ack sits outside it', () => {
|
||||
|
||||
Reference in New Issue
Block a user