mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
Match literal text across the authorized board, including cards outside lazy windows. Publish only matching IDs, refresh on content and access changes, and release observers when filters change. Verify the batched join, cancellation and permission races, and actual Chromium behavior. Thanks to neooleg and xet7 !
20 lines
774 B
JavaScript
20 lines
774 B
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import { Tracker } from 'meteor/tracker';
|
|
import { Session } from 'meteor/session';
|
|
|
|
const matches = new Mongo.Collection('boardTextMatches');
|
|
export function boardTextSelector(term) {
|
|
const boardId = Session.get('currentBoard');
|
|
return { _id: { $in: matches.find({ boardId, term }, { fields: { cardId: 1 } }).fetch().map(row => row.cardId) } };
|
|
}
|
|
export function startBoardTextFilter(filter) {
|
|
Meteor.startup(() => Tracker.autorun(computation => {
|
|
const boardId = Session.get('currentBoard'), term = filter.value();
|
|
if (boardId && term) {
|
|
const handle = Meteor.subscribe('boardTextMatches', boardId, term);
|
|
computation.onInvalidate(() => handle.stop());
|
|
}
|
|
}));
|
|
}
|