mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-14 16:37:27 +00:00
Address bar improvements
This commit is contained in:
parent
84f900b923
commit
e33b2f2f56
2 changed files with 16 additions and 2 deletions
|
@ -60,6 +60,7 @@
|
|||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.searchBarSuggestionsListUl {
|
||||
|
@ -70,8 +71,10 @@
|
|||
|
||||
.searchBarSuggestionsListItems:hover {
|
||||
background: gray;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.searchBarSuggestionsListItems.active {
|
||||
background: gray;
|
||||
color: white;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,17 @@ export const searchUrlUtils = url => {
|
|||
return [];
|
||||
};
|
||||
|
||||
const normalizeURL = url => {
|
||||
if (url.indexOf('?') === -1 && !url.endsWith('/')) {
|
||||
url = `${url}/`;
|
||||
}
|
||||
return url;
|
||||
};
|
||||
|
||||
export const updateExistingUrl = url => {
|
||||
url = normalizeURL(url);
|
||||
if (previousSearchResults?.length) {
|
||||
const updatedSearchResults = [...previousSearchResults];
|
||||
let updatedSearchResults = [...previousSearchResults];
|
||||
|
||||
const index = updatedSearchResults.findIndex(
|
||||
eachSearchResult => eachSearchResult.url === url
|
||||
|
@ -49,7 +57,10 @@ export const updateExistingUrl = url => {
|
|||
updatedSearchResults[index].visitedCount =
|
||||
1 + updatedSearchResults[index].visitedCount;
|
||||
} else {
|
||||
updatedSearchResults.push({url, visitedCount: 1});
|
||||
updatedSearchResults = [
|
||||
{url, visitedCount: 1},
|
||||
...updatedSearchResults,
|
||||
].slice(0, 300);
|
||||
}
|
||||
|
||||
addUrlToSearchResults(updatedSearchResults);
|
||||
|
|
Loading…
Reference in a new issue