feat: Introduce multi-platform architecture for Electron and Web clients with shared UI components, Convex backend for messaging, and integrated search functionality.
Some checks failed
Build and Release / build-and-release (push) Has been cancelled

This commit is contained in:
Bryan1029384756
2026-02-16 13:08:39 -06:00
parent 8ff9213b34
commit ec12313996
49 changed files with 2449 additions and 3914 deletions

View File

@@ -0,0 +1,47 @@
const FILTER_RE = /\b(from|has|mentions|before|after|in|pinned):(\S+)/gi;
export function parseFilters(rawQuery) {
const filters = {};
let textQuery = rawQuery;
let match;
while ((match = FILTER_RE.exec(rawQuery)) !== null) {
const key = match[1].toLowerCase();
const val = match[2];
switch (key) {
case 'from': filters.senderName = val; break;
case 'has':
if (val === 'link') filters.hasLink = true;
else if (val === 'file' || val === 'attachment') filters.hasFile = true;
else if (val === 'image') filters.hasImage = true;
else if (val === 'video') filters.hasVideo = true;
else if (val === 'mention') filters.hasMention = true;
break;
case 'mentions': filters.hasMention = true; filters.mentionName = val; break;
case 'before': filters.before = val; break;
case 'after': filters.after = val; break;
case 'in': filters.channelName = val; break;
case 'pinned': filters.pinned = val === 'true' || val === 'yes'; break;
}
textQuery = textQuery.replace(match[0], '');
}
FILTER_RE.lastIndex = 0;
return { textQuery: textQuery.trim(), filters };
}
/**
* Detects if the user is mid-typing a filter token.
* e.g. "hello from:par" → { prefix: 'from', partial: 'par' }
* e.g. "from:" → { prefix: 'from', partial: '' }
* Returns null if no active prefix is detected at the end of text.
*/
export function detectActivePrefix(text) {
if (!text) return null;
// Match a filter prefix at the end of the string, possibly with a partial value
const m = text.match(/\b(from|in|has|mentions):(\S*)$/i);
if (m) {
return { prefix: m[1].toLowerCase(), partial: m[2].toLowerCase() };
}
return null;
}