Skip to content

Commit

Permalink
Fix missing close icon and update dependencies (#68)
Browse files Browse the repository at this point in the history
* Fix missing close icon and updated dependencies

* Fix a bug with closing browser tab functionality

* Also display current tab in tab search view

* Prepare for v1.8.1 release

Co-authored-by: Simon Heimler <[email protected]>
  • Loading branch information
Fannon and Simon Heimler authored Dec 31, 2022
1 parent 2d83188 commit 8bb1074
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 71 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## [v1.8.1]

- **FIXED**: Missing icon for closing open tabs
- Tip: This is especially useful if you enter tab search mode via searching `t `
- **FIXED**: Improved very buggy logic to close tabs and update search results

## [v1.8.0]

- **NEW**: Allow definition of custom search engines that are triggered by custom alias
Expand Down
1 change: 1 addition & 0 deletions bin/createDist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cp manifest.json dist/chrome/manifest.json

mkdir dist/chrome/images/
cp images/edit.svg dist/chrome/images/edit.svg
cp images/edit.svg dist/chrome/images/x.svg
cp images/logo-16.png dist/chrome/images/logo-16.png
cp images/logo-32.png dist/chrome/images/logo-32.png
cp images/logo-48.png dist/chrome/images/logo-48.png
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('Search View', () => {
.type(`JSON Edit`)
.get('#result-list li')
.each((el, index) => {
console.log(el)
if (index === 0) {
expect(el[0].id).to.equal('selected-result')
} else {
Expand Down
2 changes: 1 addition & 1 deletion manifest.firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Browser extension to (fuzzy) search and navigate bookmarks, history and open tabs.",
"homepage_url": "https://github.com/Fannon/search-bookmarks-history-and-tabs",
"author": "Simon Heimler",
"version": "1.8.0",
"version": "1.8.1",
"manifest_version": 2,
"applications": {
"gecko": {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Browser extension to (fuzzy) search and navigate bookmarks, history and open tabs.",
"homepage_url": "https://github.com/Fannon/search-bookmarks-history-and-tabs",
"author": "Simon Heimler",
"version": "1.8.0",
"version": "1.8.1",
"manifest_version": 3,
"permissions": ["tabs", "bookmarks", "history", "storage"],
"action": {
Expand Down
98 changes: 49 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"mark.js": "^8.11.1"
},
"devDependencies": {
"cypress": "^12.1.0",
"cypress": "^12.2.0",
"cypress-fail-on-console-error": "^4.0.2",
"eslint": "^8.29.0",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
"live-server": "^1.2.2",
"prettier": "2.8.1",
"prettier-eslint": "^15.0.1",
"sass": "^1.56.2"
"sass": "^1.57.1"
},
"scripts": {
"clean": "rm -rf ./dist",
Expand Down
2 changes: 1 addition & 1 deletion popup/js/search/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function search(event) {
searchTerm = searchTerm.replace(/ +(?= )/g, '') // Remove duplicate spaces

ext.model.result = []
let searchMode = 'all' // OR 'bookmarks' OR 'history'
let searchMode = 'all'

// Support for various search modes
// This is detected by looking at the first chars of the search
Expand Down
16 changes: 6 additions & 10 deletions popup/js/search/defaultEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ export async function addDefaultEntries() {
})
} else if (ext.model.searchMode === 'tabs' && ext.model.tabs) {
// Display last opened tabs by default
results = ext.model.tabs
.filter((el) => {
return el.active === false
})
.map((el) => {
return {
searchScore: 1,
...el,
}
})
results = ext.model.tabs.map((el) => {
return {
searchScore: 1,
...el,
}
})
} else if (ext.model.searchMode === 'bookmarks' && ext.model.bookmarks) {
// Display all bookmarks by default
results = ext.model.bookmarks.map((el) => {
Expand Down
21 changes: 16 additions & 5 deletions popup/js/view/searchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,28 @@ export function openResultItem(event) {
window.location = '#edit-bookmark/' + originalId
return
} else if (target && target.className.includes('close-button')) {
// TODO: Tab close handling is inefficient and not smart.
const targetId = parseInt(originalId)

// Close Browser Tab
ext.browserApi.tabs.remove(parseInt(originalId))
ext.browserApi.tabs.remove(targetId)

// Remove search list entry
document.querySelector(`#result-list > li[x-original-id="${originalId}"]`).remove()
document.querySelector(`#result-list > li[x-original-id="${originalId}"]`).remove(targetId)

// Remove closed tab from index model
const index = ext.model.tabs.findIndex((el) => el.originalId === 210)
ext.model.tabs.splice(index, 1)
ext.model.tabs.splice(
ext.model.tabs.findIndex((el) => el.originalId === targetId),
1,
)

// Remove closed tab from search result
ext.model.result.splice(
ext.model.result.findIndex((el) => el.originalId === targetId),
1,
)

// Render search results again to avoid display bugs
renderSearchResults()

return
}
Expand Down

0 comments on commit 8bb1074

Please sign in to comment.