Skip to content

Commit

Permalink
feat(content): listen to edit word event
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed May 18, 2018
1 parent b24c7db commit 9188f21
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/content/redux/modules/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StoreState, DispatcherThunk, Dispatcher } from './index'
import appConfigFactory, { TCDirection, AppConfig, DictID } from '@/app-config'
import { message } from '@/_helpers/browser-api'
import { createAppConfigStream } from '@/_helpers/config-manager'
import { MsgSelection, MsgType, MsgTempDisabledState } from '@/typings/message'
import { MsgSelection, MsgType, MsgTempDisabledState, MsgEditWord } from '@/typings/message'
import { searchText, restoreDicts } from '@/content/redux/modules/dictionaries'
import { getDefaultSelectionInfo, SelectionInfo } from '@/_helpers/selection'
import { Mutable } from '@/typings/helpers'
Expand Down Expand Up @@ -386,6 +386,12 @@ export function startUpAction (): DispatcherThunk {
message.self.addListener(MsgType.EscapeKey, () => {
dispatch(closePanel())
})

// from word page
message.self.addListener<MsgEditWord>(MsgType.EditWord, ({ word }) => {
dispatch(searchText({ info: word }))
dispatch(wordEditorShouldShow(true))
})
}
}

Expand Down Expand Up @@ -453,19 +459,6 @@ export function addToNotebook (info: SelectionInfo): DispatcherThunk {
}
}

export function removeFromNotebook (word: recordManager.Word): DispatcherThunk {
return (dispatch, getState) => {
return recordManager.deleteWord('notebook', word)
.then(() => dispatch(favWord(false)))
.catch(err => {
if (process.env.NODE_ENV === 'development') {
console.error(err)
}
dispatch(favWord(false))
})
}
}

/** Fire when panel is loaded */
export function updateFaveInfo (): DispatcherThunk {
return (dispatch, getState) => {
Expand Down

0 comments on commit 9188f21

Please sign in to comment.