A number of performance tweaks
This commit is contained in:
		
					parent
					
						
							
								07689379cb
							
						
					
				
			
			
				commit
				
					
						e011589a5e
					
				
			
		
					 3 changed files with 29 additions and 28 deletions
				
			
		| 
						 | 
					@ -409,12 +409,14 @@
 | 
				
			||||||
        await this.initialPromise;
 | 
					        await this.initialPromise;
 | 
				
			||||||
        const verified = await this.safeGetVerified();
 | 
					        const verified = await this.safeGetVerified();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (this.get('verified') !== verified) {
 | 
				
			||||||
          this.set({ verified });
 | 
					          this.set({ verified });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // we don't await here because we don't need to wait for this to finish
 | 
					          // we don't await here because we don't need to wait for this to finish
 | 
				
			||||||
          window.Signal.Data.updateConversation(this.id, this.attributes, {
 | 
					          window.Signal.Data.updateConversation(this.id, this.attributes, {
 | 
				
			||||||
            Conversation: Whisper.Conversation,
 | 
					            Conversation: Whisper.Conversation,
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -516,7 +516,7 @@
 | 
				
			||||||
    findAndFormatContact(phoneNumber) {
 | 
					    findAndFormatContact(phoneNumber) {
 | 
				
			||||||
      const contactModel = this.findContact(phoneNumber);
 | 
					      const contactModel = this.findContact(phoneNumber);
 | 
				
			||||||
      if (contactModel) {
 | 
					      if (contactModel) {
 | 
				
			||||||
        return contactModel.getProps();
 | 
					        return contactModel.format();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const { format } = PhoneNumber;
 | 
					      const { format } = PhoneNumber;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -178,7 +178,9 @@
 | 
				
			||||||
        this.model.updateVerified.bind(this.model),
 | 
					        this.model.updateVerified.bind(this.model),
 | 
				
			||||||
        1000 // one second
 | 
					        1000 // one second
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      this.throttledGetProfiles = _.throttle(
 | 
					      this.model.throttledGetProfiles =
 | 
				
			||||||
 | 
					        this.model.throttledGetProfiles ||
 | 
				
			||||||
 | 
					        _.throttle(
 | 
				
			||||||
          this.model.getProfiles.bind(this.model),
 | 
					          this.model.getProfiles.bind(this.model),
 | 
				
			||||||
          1000 * 60 * 5 // five minutes
 | 
					          1000 * 60 * 5 // five minutes
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
| 
						 | 
					@ -1500,23 +1502,6 @@
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async onOpened(messageId) {
 | 
					    async onOpened(messageId) {
 | 
				
			||||||
      this.openStart = Date.now();
 | 
					 | 
				
			||||||
      this.lastActivity = Date.now();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      this.focusMessageField();
 | 
					 | 
				
			||||||
      this.model.updateLastMessage();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      const statusPromise = this.throttledGetProfiles();
 | 
					 | 
				
			||||||
      // eslint-disable-next-line more/no-then
 | 
					 | 
				
			||||||
      this.statusFetch = statusPromise.then(() =>
 | 
					 | 
				
			||||||
        // eslint-disable-next-line more/no-then
 | 
					 | 
				
			||||||
        this.model.updateVerified().then(() => {
 | 
					 | 
				
			||||||
          this.onVerifiedChange();
 | 
					 | 
				
			||||||
          this.statusFetch = null;
 | 
					 | 
				
			||||||
          window.log.info('done with status fetch');
 | 
					 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (messageId) {
 | 
					      if (messageId) {
 | 
				
			||||||
        const message = await getMessageById(messageId, {
 | 
					        const message = await getMessageById(messageId, {
 | 
				
			||||||
          Message: Whisper.Message,
 | 
					          Message: Whisper.Message,
 | 
				
			||||||
| 
						 | 
					@ -1532,10 +1517,24 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.loadNewestMessages();
 | 
					      this.loadNewestMessages();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      this.focusMessageField();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const quotedMessageId = this.model.get('quotedMessageId');
 | 
					      const quotedMessageId = this.model.get('quotedMessageId');
 | 
				
			||||||
      if (quotedMessageId) {
 | 
					      if (quotedMessageId) {
 | 
				
			||||||
        this.setQuoteMessage(quotedMessageId);
 | 
					        this.setQuoteMessage(quotedMessageId);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      this.model.updateLastMessage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      const statusPromise = this.model.throttledGetProfiles();
 | 
				
			||||||
 | 
					      // eslint-disable-next-line more/no-then
 | 
				
			||||||
 | 
					      this.statusFetch = statusPromise.then(() =>
 | 
				
			||||||
 | 
					        // eslint-disable-next-line more/no-then
 | 
				
			||||||
 | 
					        this.model.updateVerified().then(() => {
 | 
				
			||||||
 | 
					          this.onVerifiedChange();
 | 
				
			||||||
 | 
					          this.statusFetch = null;
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async retrySend(messageId) {
 | 
					    async retrySend(messageId) {
 | 
				
			||||||
| 
						 | 
					@ -2424,7 +2423,7 @@
 | 
				
			||||||
      const trimmed =
 | 
					      const trimmed =
 | 
				
			||||||
        messageText && messageText.length > 0 ? messageText.trim() : '';
 | 
					        messageText && messageText.length > 0 ? messageText.trim() : '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if ((this.model.get('draft') && !messageText) || trimmed.length === 0) {
 | 
					      if (this.model.get('draft') && (!messageText || trimmed.length === 0)) {
 | 
				
			||||||
        this.model.set({
 | 
					        this.model.set({
 | 
				
			||||||
          draft: null,
 | 
					          draft: null,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue