Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
feat: add visibility filter (#461)
Zeng1998407d1cdcaa4a
diff --git a/web/src/components/CreateShortcutDialog.tsx b/web/src/components/CreateShortcutDialog.tsxindex 641e8f117..18fc699ca 100644--- a/web/src/components/CreateShortcutDialog.tsx+++ b/web/src/components/CreateShortcutDialog.tsx@@ -173,6 +173,8 @@ const MemoFilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterInconst valueDataSource =type === "TYPE"? filterConsts["TYPE"].values.map(({ text, value }) => ({ text: t(text), value }))+ : type === "VISIBILITY"+ ? filterConsts["VISIBILITY"].values.map(({ text, value }) => ({ text: t(text), value })): tags.sort().map((t) => {return { text: t, value: t };});diff --git a/web/src/helpers/filter.ts b/web/src/helpers/filter.tsindex 6068c7ba9..4d82aad6a 100644--- a/web/src/helpers/filter.ts+++ b/web/src/helpers/filter.ts@@ -73,6 +73,34 @@ export const filterConsts = {},],},+ VISIBILITY: {+ text: "Visibility",+ value: "VISIBILITY",+ operators: [+ {+ text: "filter.operator.is",+ value: "IS",+ },+ {+ text: "filter.operator.is-not",+ value: "IS_NOT",+ },+ ],+ values: [+ {+ text: "memo.visibility.public",+ value: "PUBLIC",+ },+ {+ text: "memo.visibility.protected",+ value: "PROTECTED",+ },+ {+ text: "memo.visibility.private",+ value: "PRIVATE",+ },+ ],+ },};export const memoSpecialTypes = filterConsts["TYPE"].values;@@ -173,6 +201,12 @@ export const checkShouldShowMemo = (memo: Memo, filter: Filter) => {} else {return memo.displayTs > dayjs(value).valueOf();}+ } else if (type === "VISIBILITY") {+ let matched = memo.visibility === value;+ if (operator === "IS_NOT") {+ matched = !matched;+ }+ shouldShow = matched;}return shouldShow;diff --git a/web/src/types/filter.d.ts b/web/src/types/filter.d.tsindex a2783a3c4..43511af66 100644--- a/web/src/types/filter.d.ts+++ b/web/src/types/filter.d.ts@@ -41,6 +41,14 @@ interface DisplayTimeFilter extends BaseFilter {};}-type FilterType = "TEXT" | "TYPE" | "TAG" | "DISPLAY_TIME";+interface VisibilityFilter extends BaseFilter {+ type: "VISIBILITY";+ value: {+ operator: "IS" | "IS_NOT";+ value: string;+ };+}++type FilterType = "TEXT" | "TYPE" | "TAG" | "DISPLAY_TIME" | "VISIBILITY";-type Filter = BaseFilter | TagFilter | TypeFilter | TextFilter | DisplayTimeFilter;+type Filter = BaseFilter | TagFilter | TypeFilter | TextFilter | DisplayTimeFilter | VisibilityFilter;