Добавлено меню - всё прочитано
This commit is contained in:
parent
f08ff88cb9
commit
35a5b9583f
2 changed files with 34 additions and 1 deletions
|
|
@ -2,6 +2,8 @@ import { observer } from 'mobx-react-lite';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import * as IssuesListBoardStore from './store';
|
import * as IssuesListBoardStore from './store';
|
||||||
import * as IssuesListBoardNs from './issues-list-board';
|
import * as IssuesListBoardNs from './issues-list-board';
|
||||||
|
import * as TopRightMenuNs from '../misc-components/top-right-menu';
|
||||||
|
import { SetIssuesReadingTimestamp } from '../utils/unreaded-provider';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
store: IssuesListBoardStore.IPageStore
|
store: IssuesListBoardStore.IPageStore
|
||||||
|
|
@ -19,5 +21,18 @@ export const IssuesListBoards = observer((props: Props): JSX.Element => {
|
||||||
const board = <IssuesListBoardNs.IssuesListBoard store={boardData} key={key}/>
|
const board = <IssuesListBoardNs.IssuesListBoard store={boardData} key={key}/>
|
||||||
list.push(board);
|
list.push(board);
|
||||||
}
|
}
|
||||||
return <>{list}</>;
|
const topRightMenuStore = TopRightMenuNs.Store.create({visible: false});
|
||||||
|
const onAllReadItemClick = (e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
SetIssuesReadingTimestamp(props.store.issueIds);
|
||||||
|
IssuesListBoardStore.PageStoreLoadData(props.store);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TopRightMenuNs.TopRightMenu store={topRightMenuStore}>
|
||||||
|
<button onClick={onAllReadItemClick}>Прочитать всё</button>
|
||||||
|
</TopRightMenuNs.TopRightMenu>
|
||||||
|
{list}
|
||||||
|
</>
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -40,6 +40,24 @@ export const PageStore = types.model({
|
||||||
self.loaded = true;
|
self.loaded = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}).views((self) => {
|
||||||
|
return {
|
||||||
|
get issueIds(): number[] {
|
||||||
|
if (!self.data) return [];
|
||||||
|
const data = self.data;
|
||||||
|
const res = [] as number[];
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
const itemData = data[i];
|
||||||
|
for (let j = 0; j < itemData.data.length; j++) {
|
||||||
|
const issue = itemData.data[j];
|
||||||
|
if (res.indexOf(issue.id) < 0) {
|
||||||
|
res.push(issue.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function PageStoreLoadData(store: IPageStore): Promise<void> {
|
export async function PageStoreLoadData(store: IPageStore): Promise<void> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue