Open martinpopel opened 2 years ago
I tried make debounce more flexible (e.g. wait more time, if text is long) but is was not that easy. Now it waits 500 ms, maybe changing it to 1000 or 1500 could be still responsive enought for user.
I don't think we should try to estimate the translation time based on the text length. (Moreover, if a user pastes a long text from the clipboard, we should not wait longer than the default 500 ms.) What I am suggesting is that a new request for translation should be sent if the following two conditions are met:
debounce
).We can either set N to e.g. 10 seconds for simplicity, or double the value with each request sent (and set back to 10 once the last request is processed).
A request for translation is sent each time when the input text has changed (after some delay from the last key press), am I right? Or do we wait until the last request is processed (translation returned and shown to the user) before we send a new request?
To prevent overloading of the backend, we should increase the delay from the last key press in case the previous request was not processed yet. Once all sent requests are processed, the delay would be reset to its default value. One extreme would be to increase the delay to infinity, i.e. never send a second request, but that seems too fragile (the request could got lost). The motivation is that when the backend is under a heavy load and a user is editing a very long text, we should not send new request each second.