-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel outdated pending compose suggestions #6838
Cancel outdated pending compose suggestions #6838
Conversation
I don't get it, how do you decide what is obsolete or not? |
@LienRag the most recently-issued request is the only one which results we are interested in. Any other request that might still be running can be canceled. |
Hm, some unexpected behavior is still going on, and I'm not completely sure why: when typing something that could be a username (e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is very welcome, but new js syntax is better
@@ -11,6 +12,9 @@ import { | |||
refreshPublicTimeline, | |||
} from './timelines'; | |||
|
|||
var CancelToken = axios.CancelToken; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use let
api(getState).get('/api/v1/accounts/search', { | ||
cancelToken: new CancelToken(function (cancel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use cancel => {
for brevity
91ca509
to
7070f52
Compare
@@ -11,6 +12,9 @@ import { | |||
refreshPublicTimeline, | |||
} from './timelines'; | |||
|
|||
let CancelToken = axios.CancelToken; | |||
let _CancelFetchComposeSuggestionsAccounts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this underscore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a sign that this is to remain private to this module. But this convention doesn't appear to be used widely/consistently within Mastodon, so I guess I can drop it (and also start with a lowercase).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm for dropping this because the code knows it, even without such a symbol. The code will not allow to use the variable out of this module.
If i recall correctly, underscore as prefix is seen in some components of Mastodon, but that could make sense because the code doesn't know a variable is private, and allows to use it out of the component (if ref
is there.)
7070f52
to
b5d1ebe
Compare
@@ -1,4 +1,5 @@ | |||
import api from '../api'; | |||
import axios from 'axios'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I get it now
import axios, { CancelToken } from 'axios';
should work instead of let CancelToken
b5d1ebe
to
7546095
Compare
7546095
to
08f49bd
Compare
This PR cancels outdated compose suggestions requests to prevent outdated results to show up instead of newer (usually more precise) ones, or when the current composed text does not call for a completion.