File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -237,39 +237,16 @@ public bool FavModify(CodeBoxModel code)
237237 }
238238 return true ;
239239 }
240-
241240 public async Task < ObservableCollection < CodeBoxModel > > SearchCode ( string text , string from )
242241 {
243242 var currentCode = from == "Home" ? AllCodes : FavCodes ;
244-
245- var lst = new ObservableCollection < CodeBoxModel > ( ) ;
246- var lst2 = new ObservableCollection < CodeBoxModel > ( ) ;
247- foreach ( var code in currentCode )
243+ var newCodesList = currentCode . Where ( x => x . title . ToLower ( ) . Contains ( text . ToLower ( ) ) ) . ToList ( ) ;
244+ var newCodes = new ObservableCollection < CodeBoxModel > ( ) ;
245+ foreach ( var code in newCodesList )
248246 {
249- int f = 0 ;
250- if ( code . title . Length >= text . Length )
251- {
252- foreach ( var i in code . title )
253- {
254- if ( text . Contains ( i ) )
255- {
256- text . Remove ( text . IndexOf ( i ) ) ;
257- f ++ ;
258- }
259- }
260- }
261- else continue ;
262-
263- if ( code . title == text ) lst . Add ( code ) ;
264- else if ( code . title . Length < 3 )
265- {
266- if ( f >= 1 ) lst2 . Add ( code ) ;
267- }
268- else if ( f >= 3 ) lst2 . Add ( code ) ;
247+ newCodes . Add ( code ) ;
269248 }
270-
271- lst . Concat ( lst2 ) ;
272- return lst ;
249+ return newCodes ;
273250 }
274251 }
275252}
You can’t perform that action at this time.
0 commit comments