Skip to content

Commit

Permalink
fix(panel): replace same selection
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed May 25, 2018
1 parent c751d44 commit 5270b8e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/content/redux/modules/dictionaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ export const reducer: DictsReducer = {
dictionaries: {
...dictionaries,
// don't create history for same info
searchHistory: info === history[0] ? history : [info, ...history].slice(0, 20),
searchHistory: info === history[0]
? history
: isSameSelection(info, history[0])
? [info, ...history.slice(1, 20)]
: [info, ...history].slice(0, 20),
dicts,
}
}
Expand Down Expand Up @@ -306,7 +310,10 @@ export function searchText (arg?: { id?: DictID, info?: SelectionInfo }): Dispat
dispatch(searchStart({ toStart, toOnhold, info }))
toStart.forEach(doSearch)

if (!isSaladictInternalPage && state.config.searhHistory) {
if (!isSaladictInternalPage &&
state.config.searhHistory &&
!isSameSelection(state.config.searhHistory[0], info)
) {
saveWord('history', info)
}

Expand Down

0 comments on commit 5270b8e

Please sign in to comment.