| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -92,6 +92,7 @@ export interface ConversationAttributes {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  triggerNotificationsFor: ConversationNotificationSettingType;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  isTrustedForAttachmentDownload: boolean;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  isPinned: boolean;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  lastReadTimestamp: number;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				export interface ConversationAttributesOptionals {
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -160,6 +161,7 @@ export const fillConvoAttributesWithDefaults = (
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    triggerNotificationsFor: 'all', // if the settings is not set in the db, this is the default
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    isTrustedForAttachmentDownload: false, // we don't trust a contact until we say so
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    isPinned: false,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    lastReadTimestamp: 0,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				};
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -188,7 +190,16 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.updateLastMessage = _.throttle(this.bouncyUpdateLastMessage.bind(this), 1000);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.throttledNotify = _.debounce(this.notify, 500, { maxWait: 1000 });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    //start right away the function is called, and wait 1sec before calling it again
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.markRead = _.debounce(this.markReadBouncy, 1000, { leading: true });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    //this.markRead = _.debounce(this.markReadBouncy, 1000, { leading: true });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    const markReadBouncy = _.debounce(this.markReadBouncy, 1000, { leading: true })
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.markRead = (newestUnreadDate: number) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      const lastReadTimestamp = this.get('lastReadTimestamp');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      if (newestUnreadDate > lastReadTimestamp)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      this.set({
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        lastReadTimestamp: newestUnreadDate,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      markReadBouncy(newestUnreadDate);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    // Listening for out-of-band data updates
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    this.typingRefreshTimer = null;
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -903,6 +914,11 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  public async markReadBouncy(newestUnreadDate: number, providedOptions: any = {}) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    const lastReadTimestamp = this.get('lastReadTimestamp');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if (newestUnreadDate < lastReadTimestamp) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    const options = providedOptions || {};
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    _.defaults(options, { sendReadReceipts: true });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -948,7 +964,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      const cachedUnreadCountOnConvo = this.get('unreadCount');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      if (cachedUnreadCountOnConvo !== read.length) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // reset the unreadCount on the convo to the real one coming from markRead messages on the db
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        this.set({ unreadCount: 0 });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        this.set({ unreadCount: realUnreadCount });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        await this.commit();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      } else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // window?.log?.info('markRead(): nothing newly read.');
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |