Skip to content

Commit

Permalink
display search results only if they were retrieved for last user input (
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohlmeier authored Sep 7, 2021
1 parent 57c7b33 commit 57a693a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ let trayIcon: Tray;
let mainWindow: BrowserWindow;
let settingsWindow: BrowserWindow;
let lastWindowPosition = config.generalOptions.lastWindowPosition;
let lastSearchUserInput: string | undefined;

let translationSet = getTranslationSet(config.generalOptions.language);
const logger = appIsInDevelopment ? new DevLogger() : new ProductionLogger(logFilePath, filePathExecutor);
Expand Down Expand Up @@ -715,9 +716,14 @@ function registerAllIpcListeners() {
);

ipcMain.on(IpcChannels.search, (event: Electron.IpcMainEvent, userInput: string) => {
lastSearchUserInput = userInput;
searchEngine
.getSearchResults(userInput)
.then((result) => updateSearchResults(result, event.sender))
.then((result) => {
if (lastSearchUserInput === userInput) {
updateSearchResults(result, event.sender);
}
})
.catch((err) => {
logger.error(err);
noSearchResultsFound();
Expand Down

0 comments on commit 57a693a

Please sign in to comment.