Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic template and icon - Cleaning up each notification after it is closed is necessary #17

Open
wdmtech opened this issue Jun 23, 2017 · 0 comments

Comments

@wdmtech
Copy link

wdmtech commented Jun 23, 2017

I've written some logic that allows one to dynamically change the icon and template based on params passed to electron-notify:

  let setNotificationTemplate = level => {

    let templatePath = (process.env.NODE_ENV === 'development')
      ? Path.join(__dirname, `../../../dist/notification-templates/${level}.html`)
      : Path.join(__dirname, `./notification-templates/${level}.html`)
      
    mb.window.webContents.send('debug-error', templatePath)

    eNotify.setTemplatePath(templatePath)
  }

  let setNotificationIcon = icon => {

    let appIcon = (process.env.NODE_ENV === 'development')
      ? Path.join(__dirname, `../../../dist/imgs/${icon}.png`)
      : Path.join(__dirname, `./imgs/${icon}.png`)
      
    mb.window.webContents.send('debug-error', appIcon)

    eNotify.setConfig({appIcon})
  }

This works! However, the notification needs to be cleaned up after it has shown, or it will retain the previous parameters.

Has anyone come across a way to do this without calling closeAll() before each notification?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant