From 33b40bf35fbd04e1895ca74598716a6a0bbfca2f Mon Sep 17 00:00:00 2001 From: jacobherrington Date: Tue, 2 Oct 2018 05:26:30 -0500 Subject: [PATCH] Add notification for copying snippets --- .../modals/PreferencesModal/SnippetTab.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/browser/main/modals/PreferencesModal/SnippetTab.js b/browser/main/modals/PreferencesModal/SnippetTab.js index f16bac7b..460d33d6 100644 --- a/browser/main/modals/PreferencesModal/SnippetTab.js +++ b/browser/main/modals/PreferencesModal/SnippetTab.js @@ -8,6 +8,8 @@ import SnippetList from './SnippetList' import eventEmitter from 'browser/main/lib/eventEmitter' import copy from 'copy-to-clipboard' +const path = require('path') + class SnippetTab extends React.Component { constructor (props) { super(props) @@ -17,6 +19,17 @@ class SnippetTab extends React.Component { this.changeDelay = null } + notify (title, options) { + if (global.process.platform === 'win32') { + options.icon = path.join( + 'file://', + global.__dirname, + '../../resources/app.png' + ) + } + return new window.Notification(title, options) + } + handleSnippetNameOrPrefixChange () { clearTimeout(this.changeDelay) this.changeDelay = setTimeout(() => { @@ -56,7 +69,14 @@ class SnippetTab extends React.Component { } handleCopySnippet (e) { + const showCopyNotification = this.props.config.ui.showCopyNotification copy(this.state.currentSnippet.content) + if (showCopyNotification) { + this.notify('Saved to Clipboard!', { + body: 'Paste it wherever you want!', + silent: true + }) + } } render () {