diff options
| author | bobzel <zzzman@gmail.com> | 2020-08-06 22:30:36 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2020-08-06 22:30:36 -0400 |
| commit | a1977d1ae00a4f0c3907eb243ba1c04a5acc5c62 (patch) | |
| tree | 66bbd9b9b912c30f893c2204716ff8e4f9086019 /src/client/views/MainViewNotifs.tsx | |
| parent | 72b95c76f156a15f645703ba77c05aeb62c903ff (diff) | |
| parent | 0910e7387fae485d7c11eb71b6abcce865403b13 (diff) | |
Merge branch 'master' into new_audio
Diffstat (limited to 'src/client/views/MainViewNotifs.tsx')
| -rw-r--r-- | src/client/views/MainViewNotifs.tsx | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/client/views/MainViewNotifs.tsx b/src/client/views/MainViewNotifs.tsx index 05f890485..ce47e1cf1 100644 --- a/src/client/views/MainViewNotifs.tsx +++ b/src/client/views/MainViewNotifs.tsx @@ -3,28 +3,33 @@ import { observer } from 'mobx-react'; import "normalize.css"; import * as React from 'react'; import { Doc, DocListCast, Opt } from '../../fields/Doc'; -import { emptyFunction } from '../../Utils'; -import { SetupDrag } from '../util/DragManager'; +import { emptyFunction, returnFalse, setupMoveUpEvents } from '../../Utils'; +import { SetupDrag, DragManager } from '../util/DragManager'; import "./MainViewNotifs.scss"; -import { CollectionDockingView } from './collections/CollectionDockingView'; +import { MainView } from './MainView'; @observer export class MainViewNotifs extends React.Component { - @observable static NotifsCol: Opt<Doc>; - openNotifsCol = () => { - if (MainViewNotifs.NotifsCol) { - CollectionDockingView.AddRightSplit(MainViewNotifs.NotifsCol); - } + _notifsRef = React.createRef<HTMLDivElement>(); + + onPointerDown = (e: React.PointerEvent) => { + setupMoveUpEvents(this, e, + (e: PointerEvent) => { + const dragData = new DragManager.DocumentDragData([MainViewNotifs.NotifsCol!]); + DragManager.StartDocumentDrag([this._notifsRef.current!], dragData, e.x, e.y); + return true; + }, + returnFalse, + () => MainViewNotifs.NotifsCol && MainView.Instance.selectMenu(MainViewNotifs.NotifsCol, "Sharing")); } + render() { const length = MainViewNotifs.NotifsCol ? DocListCast(MainViewNotifs.NotifsCol.data).length : 0; - const notifsRef = React.createRef<HTMLDivElement>(); - const dragNotifs = action(() => MainViewNotifs.NotifsCol!); - return <div className="mainNotifs-container" ref={notifsRef}> + return <div className="mainNotifs-container" style={{ width: 15, height: 15 }} ref={this._notifsRef}> <button className="mainNotifs-badge" style={length > 0 ? { "display": "initial" } : { "display": "none" }} - onClick={this.openNotifsCol} onPointerDown={MainViewNotifs.NotifsCol ? SetupDrag(notifsRef, dragNotifs) : emptyFunction}> + onPointerDown={this.onPointerDown} > {length} </button> </div>; |
