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
fix: tag query filter
email6a40be9f8e28
diff --git a/web/src/components/MemoList.tsx b/web/src/components/MemoList.tsxindex 20bb23610..4c283895a 100644--- a/web/src/components/MemoList.tsx+++ b/web/src/components/MemoList.tsx@@ -19,23 +19,36 @@ const MemoList: React.FC<Props> = () => {const wrapperElement = useRef<HTMLDivElement>(null);const { tag: tagQuery, duration, type: memoType, text: textQuery, filter: queryId } = query;- const showMemoFilter = Boolean(tagQuery || (duration && duration.from < duration.to) || memoType || textQuery);+ const queryFilter = queryService.getQueryById(queryId);+ const showMemoFilter = Boolean(tagQuery || (duration && duration.from < duration.to) || memoType || textQuery || queryFilter);const shownMemos =- showMemoFilter || queryId+ showMemoFilter || queryFilter? memos.filter((memo) => {let shouldShow = true;- const query = queryService.getQueryById(queryId);- if (query) {- const filters = JSON.parse(query.querystring) as Filter[];+ if (queryFilter) {+ const filters = JSON.parse(queryFilter.querystring) as Filter[];if (Array.isArray(filters)) {shouldShow = checkShouldShowMemoWithFilters(memo, filters);}}- if (tagQuery && !memo.content.includes(`#${tagQuery} `) && !memo.content.includes(`# ${tagQuery} `)) {- shouldShow = false;+ if (tagQuery) {+ const tagsSet = new Set<string>();+ for (const t of Array.from(memo.content.match(TAG_REG) ?? [])) {+ const tag = t.replace(TAG_REG, "$1").trim();+ const items = tag.split("/");+ let temp = "";+ for (const i of items) {+ temp += i;+ tagsSet.add(temp);+ temp += "/";+ }+ }+ if (!tagsSet.has(tagQuery)) {+ shouldShow = false;+ }}if (duration &&diff --git a/web/src/components/TagList.tsx b/web/src/components/TagList.tsxindex a5d14c663..620811422 100644--- a/web/src/components/TagList.tsx+++ b/web/src/components/TagList.tsx@@ -100,7 +100,7 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContainif (isActive) {locationService.setTagQuery("");} else {- utils.copyTextToClipboard(`# ${tag.text} `);+ utils.copyTextToClipboard(`#${tag.text} `);if (!["/", "/recycle"].includes(locationService.getState().pathname)) {locationService.setPathname("/");}diff --git a/web/src/helpers/filter.ts b/web/src/helpers/filter.tsindex 68d1ca7c7..9c6d985c3 100644--- a/web/src/helpers/filter.ts+++ b/web/src/helpers/filter.ts@@ -119,7 +119,21 @@ export const checkShouldShowMemo = (memo: Model.Memo, filter: Filter) => {let shouldShow = true;if (type === "TAG") {- let contained = memo.content.includes(`#${value} `) || memo.content.includes(`# ${value} `);+ let contained = true;+ const tagsSet = new Set<string>();+ for (const t of Array.from(memo.content.match(TAG_REG) ?? [])) {+ const tag = t.replace(TAG_REG, "$1").trim();+ const items = tag.split("/");+ let temp = "";+ for (const i of items) {+ temp += i;+ tagsSet.add(temp);+ temp += "/";+ }+ }+ if (!tagsSet.has(value)) {+ contained = false;+ }if (operator === "NOT_CONTAIN") {contained = !contained;}diff --git a/web/src/pages/MemoTrash.tsx b/web/src/pages/MemoTrash.tsxindex c54d6548e..43b6e7a7d 100644--- a/web/src/pages/MemoTrash.tsx+++ b/web/src/pages/MemoTrash.tsx@@ -37,8 +37,21 @@ const MemoTrash: React.FC<Props> = () => {}}- if (tagQuery && !memo.content.includes(`# ${tagQuery}`)) {- shouldShow = false;+ if (tagQuery) {+ const tagsSet = new Set<string>();+ for (const t of Array.from(memo.content.match(TAG_REG) ?? [])) {+ const tag = t.replace(TAG_REG, "$1").trim();+ const items = tag.split("/");+ let temp = "";+ for (const i of items) {+ temp += i;+ tagsSet.add(temp);+ temp += "/";+ }+ }+ if (!tagsSet.has(tagQuery)) {+ shouldShow = false;+ }}if (duration &&