send status on ctrl+enter (#81)
* send status on ctrl+enter (#24) * don't check for floating post button when pressing ctrl+enter oops, I was too eager. it doesn't matter too much, except that if the main compose form is off-screen but still focused, ctrl+enter would open the compose modal instead of posting
This commit is contained in:
		
							parent
							
								
									a150613b53
								
							
						
					
					
						commit
						8e08d08712
					
				
					 2 changed files with 33 additions and 22 deletions
				
			
		| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
      <ComposeContentWarning :realm :contentWarning />
 | 
			
		||||
    </div>
 | 
			
		||||
  {{/if}}
 | 
			
		||||
  <ComposeInput :realm :text :autoFocus />
 | 
			
		||||
  <ComposeInput :realm :text :autoFocus on:postAction="onPostAction()" />
 | 
			
		||||
  <ComposeLengthGauge :length :overLimit />
 | 
			
		||||
  <ComposeToolbar :realm :postPrivacy :media :contentWarningShown :text />
 | 
			
		||||
  <ComposeLengthIndicator :length :overLimit />
 | 
			
		||||
| 
						 | 
				
			
			@ -188,6 +188,10 @@
 | 
			
		|||
          dialogs.showComposeDialog()
 | 
			
		||||
        } else {
 | 
			
		||||
          // else we're actually posting a new toot
 | 
			
		||||
          this.onPostAction();
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      onPostAction() {
 | 
			
		||||
        let text = this.get('text')
 | 
			
		||||
        let media = this.get('media')
 | 
			
		||||
        let postPrivacyKey = this.get('postPrivacyKey')
 | 
			
		||||
| 
						 | 
				
			
			@ -206,7 +210,6 @@
 | 
			
		|||
        /* no await */
 | 
			
		||||
        postStatus(realm, text, inReplyTo, mediaIds,
 | 
			
		||||
          sensitive, contentWarning, postPrivacyKey, mediaDescriptions)
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      setupStickyObserver() {
 | 
			
		||||
        this.__stickyObserver = new IntersectionObserver(entries => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -101,11 +101,18 @@
 | 
			
		|||
      },
 | 
			
		||||
      onKeydown(e) {
 | 
			
		||||
        let { keyCode } = e
 | 
			
		||||
        const ctrlPressed =
 | 
			
		||||
          e.getModifierState('Control') || e.getModifierState('Meta')
 | 
			
		||||
        switch (keyCode) {
 | 
			
		||||
          case 9: // tab
 | 
			
		||||
          case 13: //enter
 | 
			
		||||
            this.clickSelectedAutosuggestion(e)
 | 
			
		||||
            break
 | 
			
		||||
          case 13: //enter
 | 
			
		||||
            const autosuggestionClicked = this.clickSelectedAutosuggestion(e)
 | 
			
		||||
            if (!autosuggestionClicked && ctrlPressed) {
 | 
			
		||||
              this.fire('postAction')
 | 
			
		||||
            }
 | 
			
		||||
            break
 | 
			
		||||
          case 38: // up
 | 
			
		||||
            this.incrementAutosuggestSelected(-1, e)
 | 
			
		||||
            break
 | 
			
		||||
| 
						 | 
				
			
			@ -121,7 +128,7 @@
 | 
			
		|||
      clickSelectedAutosuggestion(event) {
 | 
			
		||||
        let autosuggestionShown = this.store.get('composeAutosuggestionShown')
 | 
			
		||||
        if (!autosuggestionShown) {
 | 
			
		||||
          return
 | 
			
		||||
          return false
 | 
			
		||||
        }
 | 
			
		||||
        let type = this.store.get('composeAutosuggestionType')
 | 
			
		||||
        if (type === 'account') {
 | 
			
		||||
| 
						 | 
				
			
			@ -131,6 +138,7 @@
 | 
			
		|||
        }
 | 
			
		||||
        event.preventDefault()
 | 
			
		||||
        event.stopPropagation()
 | 
			
		||||
        return true
 | 
			
		||||
      },
 | 
			
		||||
      incrementAutosuggestSelected(increment, event) {
 | 
			
		||||
        let autosuggestionShown = this.store.get('composeAutosuggestionShown')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue