Skip to content

Commit

Permalink
generate favicon on add bookmark
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmid committed May 29, 2020
1 parent c7a7b99 commit 0e4b79b
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 24 deletions.
21 changes: 14 additions & 7 deletions app-source/js/favicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports.regenerate = function ( winId ) {
if ( err ) return console.error( err )

log.info( `deleted cached favicons` )
module.exports.generate( winId, true )
module.exports.generate( winId, false, true )
})
}

Expand All @@ -51,7 +51,7 @@ function notify( title, body ) {



module.exports.generate = function ( winId, notify ) {
module.exports.generate = function ( winId, singleBookmark, notify ) {

let win = BrowserWindow.fromId( winId ),
bookmarks = new Store( {name: 'bookmarks'} ),
Expand All @@ -60,13 +60,20 @@ module.exports.generate = function ( winId, notify ) {
faviconCount = 0,
faviconArray = []

for( let bookmark of bookmarkData ) {
if( singleBookmark ) {

if( !defaultArray.includes( bookmark.id ) &&
!fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png`
) ) {
faviconArray.push( singleBookmark )

} else {

for( let bookmark of bookmarkData ) {

faviconArray.push( bookmark )
if( !defaultArray.includes( bookmark.id ) &&
!fs.pathExistsSync( `${dir}/favicons/${bookmark.id}.png`
) ) {

faviconArray.push( bookmark )
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion app-source/js/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ module.exports.bookmarksApi = function( call, id, data, callback ) {

break

//todo - not needed
case 'single': callback( message )
break

default: callback()
default: callback( message )
}

}).catch(function( error ) {
Expand Down
8 changes: 7 additions & 1 deletion app-source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function createWindow() {
win.once('ready-to-show', () => {

win.show()
favicons.generate( win.id, false )
favicons.generate( win.id, false, false )
})

win.on('resize', saveWindowBounds)
Expand Down Expand Up @@ -247,6 +247,12 @@ ipcMain.on('refresh', (event, message) => {



ipcMain.on('update-favicon', (event, message) => {

favicons.generate( win.id, message, false )
})


ipcMain.on('loginflow', (event, message) => {

loginFlow = new BrowserWindow({
Expand Down
5 changes: 4 additions & 1 deletion app-source/js/modal-add-bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ $(document).ready(function() {
data += '&folders[]=' + encodeURIComponent(folder['id'])
}

fetch.bookmarksApi( 'add', '', data, function() {
fetch.bookmarksApi( 'add', '', data, function( message ) {

let returnedBookmark = JSON.parse( message )
ipc.send('update-favicon', returnedBookmark['item'] )

ipc.send('refresh', 'refresh')
closeModal()
Expand Down
21 changes: 14 additions & 7 deletions dist/js/favicons.min.js

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

3 changes: 2 additions & 1 deletion dist/js/fetch.min.js

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

8 changes: 7 additions & 1 deletion dist/js/main.min.js

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

2 changes: 1 addition & 1 deletion dist/js/maps/favicons.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/maps/fetch.min.js.map

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

Loading

0 comments on commit 0e4b79b

Please sign in to comment.