diff options
Diffstat (limited to 'src/client/views/search/IconButton.tsx')
-rw-r--r-- | src/client/views/search/IconButton.tsx | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/client/views/search/IconButton.tsx b/src/client/views/search/IconButton.tsx index e10074c9f..9af4b3a93 100644 --- a/src/client/views/search/IconButton.tsx +++ b/src/client/views/search/IconButton.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { observer } from 'mobx-react'; -import { observable, action, runInAction } from 'mobx'; +import { observable, action, runInAction, IReactionDisposer, reaction } from 'mobx'; import "./SearchBox.scss"; import "./IconBar.scss"; import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons'; @@ -9,6 +9,7 @@ import { library, icon } from '@fortawesome/fontawesome-svg-core'; import { DocTypes } from '../../documents/Documents'; import '../globalCssVariables.scss'; import * as _ from "lodash"; +import { IconBar } from './IconBar'; library.add(faSearch); library.add(faObjectGroup); @@ -27,10 +28,6 @@ interface IconButtonProps { onClick(type: string): void; getList(): string[]; updateList(list: string[]): void; - resetSelf(): void; - // addToSelected(type: string): void; - // removeFromSelected(type: string): void; - // resetAddedAndRemoved(): void; } @observer @@ -42,12 +39,30 @@ export class IconButton extends React.Component<IconButtonProps>{ @observable removeType = false; @observable hover = false; + private _reactionDisposer?: IReactionDisposer; + static Instance: IconButton; - constructor(props: IconButtonProps){ + constructor(props: IconButtonProps) { super(props); IconButton.Instance = this; } + componentDidMount() { + this._reactionDisposer = reaction( + () => IconBar.Instance.ResetClicked, + () => { + if (IconBar.Instance.ResetClicked) { + this.reset() + IconBar.Instance.Reset++; + if (IconBar.Instance.Reset === 9) { + IconBar.Instance.Reset = 0; + IconBar.Instance.ResetClicked = false; + } + } + } + ) + } + @action downKeyHandler = (e: KeyboardEvent) => { if (e.key !== "Control") return; @@ -162,11 +177,11 @@ export class IconButton extends React.Component<IconButtonProps>{ //if it is selected already else { this.isSelected = false; - if(this.isAdded){ + if (this.isAdded) { this.isAdded = false; _.pull(newList, this.props.type); } - if(this.isRemoved){ + if (this.isRemoved) { this.isRemoved = false; newList.push(this.props.type) } @@ -187,12 +202,10 @@ export class IconButton extends React.Component<IconButtonProps>{ selectedRemoved = { opacity: 0.2, - // backgroundColor: "red" } notSelected = { opacity: 0.6, - // backgroundColor: "red" } hoverStyle = { @@ -211,7 +224,6 @@ export class IconButton extends React.Component<IconButtonProps>{ @action.bound public reset() { - console.log("resetting ", this.props.type) this.isSelected = false; this.isAdded = false; this.isRemoved = false; |