feat: visibility click filter (#463)

* feat: visibility click filter

* update

Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
Zeng1998
2022-11-13 21:23:40 +08:00
committed by GitHub
parent a90acdabb3
commit d208731f5f
5 changed files with 42 additions and 5 deletions

View File

@ -195,6 +195,15 @@ const Memo: React.FC<Props> = (props: Props) => {
editorStateService.setEditMemoWithId(memo.id);
};
const handleMemoVisibilityClick = (visibility: Visibility) => {
const currVisibilityQuery = locationService.getState().query?.visibility;
if (currVisibilityQuery === visibility) {
locationService.setMemoVisibilityQuery(undefined);
} else {
locationService.setMemoVisibilityQuery(visibility);
}
};
return (
<div className={`memo-wrapper ${"memos-" + memo.id} ${memo.pinned ? "pinned" : ""}`} ref={memoContainerRef}>
{memo.pinned && <div className="corner-container"></div>}
@ -204,7 +213,12 @@ const Memo: React.FC<Props> = (props: Props) => {
{displayTimeStr}
</span>
{memo.visibility !== "PRIVATE" && !isVisitorMode && (
<span className={`status-text ${memo.visibility.toLocaleLowerCase()}`}>{memo.visibility}</span>
<span
className={`status-text ${memo.visibility.toLocaleLowerCase()}`}
onClick={() => handleMemoVisibilityClick(memo.visibility)}
>
{memo.visibility}
</span>
)}
</div>
{!isVisitorMode && (