@@ -3,7 +3,7 @@ import type { Notification } from '../../../typesGitHub';
33
44export const SEARCH_DELIMITER = ':' ;
55
6- export const SEARCH_QUALIFIERS = {
6+ const SEARCH_QUALIFIERS = {
77 author : {
88 prefix : 'author:' ,
99 description : 'filter by notification author' ,
@@ -25,23 +25,13 @@ export const SEARCH_QUALIFIERS = {
2525 } ,
2626} as const ;
2727
28- export type SearchQualifierKey = keyof typeof SEARCH_QUALIFIERS ;
29- export type SearchQualifier = ( typeof SEARCH_QUALIFIERS ) [ SearchQualifierKey ] ;
28+ type SearchQualifierKey = keyof typeof SEARCH_QUALIFIERS ;
29+ type SearchQualifier = ( typeof SEARCH_QUALIFIERS ) [ SearchQualifierKey ] ;
3030export type SearchPrefix = SearchQualifier [ 'prefix' ] ;
3131
32- export const SEARCH_PREFIXES : readonly SearchPrefix [ ] = Object . values (
32+ export const QUALIFIERS : readonly SearchQualifier [ ] = Object . values (
3333 SEARCH_QUALIFIERS ,
34- ) . map ( ( q ) => q . prefix ) as readonly SearchPrefix [ ] ;
35-
36- // Map prefix -> qualifier for fast lookup after prefix detection
37- export const QUALIFIER_BY_PREFIX : Record < SearchPrefix , SearchQualifier > =
38- Object . values ( SEARCH_QUALIFIERS ) . reduce (
39- ( acc , q ) => {
40- acc [ q . prefix as SearchPrefix ] = q ;
41- return acc ;
42- } ,
43- { } as Record < SearchPrefix , SearchQualifier > ,
44- ) ;
34+ ) as readonly SearchQualifier [ ] ;
4535
4636export const AUTHOR_PREFIX : SearchPrefix = SEARCH_QUALIFIERS . author . prefix ;
4737export const ORG_PREFIX : SearchPrefix = SEARCH_QUALIFIERS . org . prefix ;
@@ -73,10 +63,9 @@ export function hasExcludeSearchFilters(settings: SettingsState) {
7363}
7464
7565export function matchQualifierByPrefix ( token : string ) {
76- // Iterate prefixes (tiny list) then direct map lookup; preserves ordering behavior
77- for ( const prefix of SEARCH_PREFIXES ) {
78- if ( token . startsWith ( prefix ) ) {
79- return QUALIFIER_BY_PREFIX [ prefix ] || null ;
66+ for ( const qualifier of QUALIFIERS ) {
67+ if ( token . startsWith ( qualifier . prefix ) ) {
68+ return qualifier ;
8069 }
8170 }
8271 return null ;
@@ -115,18 +104,18 @@ export function normalizeSearchInputToToken(raw: string): string | null {
115104 }
116105
117106 const lower = value . toLowerCase ( ) ;
118- const matched = SEARCH_PREFIXES . find ( ( p ) => lower . startsWith ( p ) ) ;
107+ const matchedQualifier = QUALIFIERS . find ( ( q ) => lower . startsWith ( q . prefix ) ) ;
119108
120- if ( ! matched ) {
109+ if ( ! matchedQualifier ) {
121110 return null ;
122111 }
123112
124- const rest = value . substring ( matched . length ) ;
113+ const rest = value . substring ( matchedQualifier . prefix . length ) ;
125114 if ( rest . length === 0 ) {
126115 return null ; // prefix only, incomplete token
127116 }
128117
129- return `${ matched } ${ rest } ` ;
118+ return `${ matchedQualifier . prefix } ${ rest } ` ;
130119}
131120
132121export function filterNotificationBySearchTerm (
0 commit comments