Skip to content

Commit 9b55483

Browse files
committed
-added debounce to search bar function
-added v17 names to contributors
1 parent c8ee9c5 commit 9b55483

File tree

5 files changed

+42
-46
lines changed

5 files changed

+42
-46
lines changed

Dockerrun.aws.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/src/components/marketplace/Searchbar.tsx

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,51 @@ const SearchBar = ({marketplaceProjects, updateDisplayProjects }):JSX.Element =>
55
//passing down all marketplaceProjects
66
const [searchText, setSearchText] = useState('');
77

8-
98
const handleChange = (e) => {
109
const newText = e.target.value
11-
setSearchText(newText)
10+
11+
setSearchText(newText)
1212

1313
}
1414

15-
1615
useEffect(()=>{
1716
if(searchText === ''){
1817

1918
updateDisplayProjects(marketplaceProjects)
19+
return;
20+
}
21+
function searching () {
2022

21-
}else{
22-
23-
//more strict pattern not currently used
24-
//const patternString = '(?:^|[^a-zA-Z])' + searchText.toLowerCase() + '(?:$|[^a-zA-Z])';
25-
//(?: [non-capturing group] means to ignore the items inside the parens in terms of looking for that string order in the target
26-
//^ refers to the literal beginning of a start of a line or string
27-
//| pipe operator is an OR statement
28-
//[^a-zA-Z] [] is grouping characters, the ^ at the beginning means to look for things that are not letters (lowercase or uppercase)
29-
//a-zA-Z letters (lowercase and uppercase) and underscore symbol
30-
//All together: match either the start/end of a line/string or any character that is not a letter.
31-
//Looks for anything that has the searchText in between non-letter characters
32-
const patternString2 = '(?:^|.)' + searchText.toLowerCase() + '(?:$|.)';
33-
//Only difference is that (?:^|.) (?:$|.) look for anything that matches the string in between any other characters for the username search
34-
//test3 and 1test) would both match for string 'test'
35-
36-
const searchResults = marketplaceProjects.reduce((results, curr) => {
37-
const lowName = curr.name.toLowerCase()
38-
const lowUsername = curr.username.toLowerCase()
39-
if(lowName.match(patternString2) || lowUsername.match(patternString2))
40-
results.push(curr)
41-
return results;
42-
}, [])
43-
updateDisplayProjects(searchResults)
23+
//more strict pattern not currently used
24+
//const patternString = '(?:^|[^a-zA-Z])' + searchText.toLowerCase() + '(?:$|[^a-zA-Z])';
25+
//(?: [non-capturing group] means to ignore the items inside the parens in terms of looking for that string order in the target
26+
//^ refers to the literal beginning of a start of a line or string
27+
//| pipe operator is an OR statement
28+
//[^a-zA-Z] [] is grouping characters, the ^ at the beginning means to look for things that are not letters (lowercase or uppercase)
29+
//a-zA-Z letters (lowercase and uppercase) and underscore symbol
30+
//All together: match either the start/end of a line/string or any character that is not a letter.
31+
//Looks for anything that has the searchText in between non-letter characters
32+
const patternString2 = '(?:^|.)' + searchText.toLowerCase() + '(?:$|.)';
33+
//Only difference is that (?:^|.) (?:$|.) look for anything that matches the string in between any other characters for the username search
34+
//test3 and 1test) would both match for string 'test'
35+
36+
const searchResults = marketplaceProjects.reduce((results, curr) => {
37+
const lowName = curr.name.toLowerCase()
38+
const lowUsername = curr.username.toLowerCase()
39+
if(lowName.match(patternString2) || lowUsername.match(patternString2))
40+
results.push(curr)
41+
return results;
42+
}, [])
43+
updateDisplayProjects(searchResults)
4444
}
4545

46+
// simple debounce
47+
const debounceTimer = setTimeout(() => {
48+
searching();
49+
}, 800);
50+
// clears the timer if searchText is changed before the setTimeout duration is reached
51+
return () => clearTimeout(debounceTimer);
52+
4653
}, [searchText])
4754

4855

app/src/components/right/DeleteProjects.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function ProjectsDialog(props: ProjectDialogProps) {
4545
(project: any) => project._id === value
4646
)[0];
4747
deleteProject(selectedProject);
48-
localforage.removeItem(window.localStorage.getItem('ssid'));
48+
// localforage.removeItem(window.localStorage.getItem('ssid'));
4949
dispatch(setInitialState(initialState))
5050
// handleAlertOpen()
5151
deleteAlert()

app/src/helperFunctions/projectGetSaveDel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const getProjects = (): Promise<any> => {
2020
})
2121
.then((res) => res.json())
2222
.then((data) => {
23-
console.log('........................ data', data)
2423
return data;
2524
})
2625
.catch((err) => console.log(`Error getting project ${err}`));

contributors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
Ahsan Rao [LinkedIn](https://www.linkedin.com/in/ahsan-rao/) [Github](https://github.com/ahsan-rao)
66

7+
[Ahnaf Khan](https://www.linkedin.com/in/ahnaf-khan-844a70193) [Github](https://github.com/AhnafKhvn)
8+
79
[Alex Yu](https://www.linkedin.com/in/alexjihunyu/) [@buddhajjigae](https://github.com/buddhajjigae)
810

911
[Aaron Bumanglag](https://www.linkedin.com/in/akbuma) [@akbuma](https://github.com/akbuma)
@@ -62,6 +64,8 @@ Darin Ngau [LinkedIn](https://www.linkedin.com/in/darin-ngau/) [Github](https://
6264

6365
[Garrett Huston](https://www.linkedin.com/in/garrett-hutson/) [Github](https://github.com/GarrettHutson)
6466

67+
[Hernan Damazo](https://www.linkedin.com/in/raul-hernan-damazo-chang-9440ab191/) [Github](https://github.com/raulclassico7)
68+
6569
[Huy Pham](https://www.linkedin.com/in/huypham048) [@huypham048](https://github.com/huypham048)
6670

6771
[Ian Davis](https://www.linkedin.com/in/icdavis/) [Github](https://github.com/iancdavis)
@@ -82,6 +86,8 @@ Darin Ngau [LinkedIn](https://www.linkedin.com/in/darin-ngau/) [Github](https://
8286

8387
[Khuong Nguyen](https://www.linkedin.com/in/khuong-nguyen/) [@khuongdn16](https://github.com/khuongdn16)
8488

89+
[Liam Roh](https://www.linkedin.com/in/liam-roh/) [Github](https://github.com/liamroh)
90+
8591
[Lillian Wimberly](https://www.linkedin.com/in/lillianwimberly/) [@lillwimberly](https://github.com/lillwimberly)
8692

8793
[Linh Tran](https://www.linkedin.com/in/linhtran51/) [@Linhatran](https://github.com/Linhatran)
@@ -136,6 +142,8 @@ Thomas Lukasiewicz [LinkedIn](https://www.linkedin.com/in/thomas-lukasiewicz-276
136142

137143
[Ulrich Neujahr](https://www.linkedin.com/in/nobrackets/) [@nobrackets](https://github.com/nobrackets)
138144

145+
[Victor Martins](https://www.linkedin.com/in/victor-martins-542611186/) [Github](https://github.com/martins5225)
146+
139147
[William Cheng](https://www.linkedin.com/in/william-cheng-0723/) [@williamcheng12345](https://github.com/WilliamCheng12345)
140148

141149
[William Rittwage](https://www.linkedin.com/in/william-rittwage) [@wbrittwage](https://github.com/wbrittwage)

0 commit comments

Comments
 (0)