diff --git a/app/actions/index.js b/app/actions/index.js index 32e40d83..dc02bfa5 100644 --- a/app/actions/index.js +++ b/app/actions/index.js @@ -1,5 +1,5 @@ import { getGitHubApi, GET_SINGLE_GIST } from '../utilities/githubApi' -import Notifier from '../utilities/notifier' +import { notifyFailure } from '../utilities/notifier' import { remote } from 'electron' const logger = remote.getGlobal('logger') @@ -232,7 +232,7 @@ export function fetchSingleGist (oldGist, id) { }) .catch((err) => { logger.error('The request has failed: ' + err) - Notifier('Sync failed', 'Please check your network condition. 01') + notifyFailure('Sync failed', 'Please check your network condition. 01') }) } } diff --git a/app/containers/snippet/index.js b/app/containers/snippet/index.js index 1f32c670..4269cbc2 100755 --- a/app/containers/snippet/index.js +++ b/app/containers/snippet/index.js @@ -7,7 +7,7 @@ import Autolinker from 'autolinker' import CodeArea from '../codeArea' import HumanReadableTime from 'human-readable-time' import Moment from 'moment' -import Notifier from '../../utilities/notifier' +import { notifySuccess, notifyFailure } from '../../utilities/notifier' import React, { Component } from 'react' import { addLangPrefix as Prefixed, @@ -78,11 +78,11 @@ class Snippet extends Component { .catch(err => { logger.error('Failed to delete the gist ' + activeGist) logger.error(JSON.stringify(err)) - Notifier('Deletion failed', 'Please check your network condition. 02') + notifyFailure('Deletion failed', 'Please check your network condition. 02') }) .then(data => { logger.info('The gist ' + activeGist + ' has been deleted.') - Notifier('The gist has been deleted') + notifySuccess('The gist has been deleted') // For performance purpose, we should perform an internal update, like what // we're doing for creating/edit gists. However, since delete is an infrequent @@ -156,7 +156,7 @@ class Snippet extends Component { description, processedFiles) .catch((err) => { - Notifier('Gist update failed') + notifyFailure('Gist update failed') logger.error(JSON.stringify(err)) }) .then((response) => { @@ -277,7 +277,7 @@ class Snippet extends Component { filename: filenameRecords }) - Notifier('Gist updated', HumanReadableTime(new Date())) + notifySuccess('Gist updated', HumanReadableTime(new Date())) } renderGistEditorModalBody (description, fileArray, isPrivate) { @@ -328,12 +328,12 @@ class Snippet extends Component { handleCopyGistLinkClicked (snippet, file) { const link = snippet.details.html_url + '#file-' + file.filename.replace(/\./g, '-').toLowerCase() clipboard.writeText(link) - Notifier('Copied', 'The link has been copied to the clipboard.') + notifySuccess('Copied', 'The link has been copied to the clipboard.') } handleCopyGistFileClicked (gist) { clipboard.writeText(gist.content) - Notifier('Copied', 'The content has been copied to the clipboard.') + notifySuccess('Copied', 'The content has been copied to the clipboard.') } showRawModalModal (gist) { @@ -375,7 +375,7 @@ class Snippet extends Component { handleCopyRawLinkClicked (url) { clipboard.writeText(url) - Notifier('Copied', 'The raw file link has been copied to the clipboard.') + notifySuccess('Copied', 'The raw file link has been copied to the clipboard.') } renderPanelHeader (activeSnippet) { diff --git a/app/containers/userPanel/index.js b/app/containers/userPanel/index.js index 491e7b15..6afac0d0 100644 --- a/app/containers/userPanel/index.js +++ b/app/containers/userPanel/index.js @@ -4,7 +4,7 @@ import { default as GistEditorForm, NEW_GIST } from '../gistEditorForm' import { Image, Modal, Button, ProgressBar } from 'react-bootstrap' import { remote, ipcRenderer } from 'electron' import HumanReadableTime from 'human-readable-time' -import Notifier from '../../utilities/notifier' +import { notifySuccess, notifyFailure } from '../../utilities/notifier' import React, { Component } from 'react' import { addLangPrefix as Prefixed, @@ -78,7 +78,7 @@ class UserPanel extends Component { return getGitHubApi(CREATE_SINGLE_GIST)(this.props.accessToken, description, processedFiles, isPublic) .catch((err) => { - Notifier('Gist creation failed') + notifyFailure('Gist creation failed') logger.error(JSON.stringify(err)) }) .then((response) => { @@ -162,7 +162,7 @@ class UserPanel extends Component { filename: filenameRecords }) - Notifier('Gist created', HumanReadableTime(new Date())) + notifySuccess('Gist created', HumanReadableTime(new Date())) } renderGistEditorModalBody () { diff --git a/app/index.js b/app/index.js index c823cfda..6cb11a4b 100644 --- a/app/index.js +++ b/app/index.js @@ -45,7 +45,7 @@ import { updatePinnedTags } from './actions/index' -import Notifier from './utilities/notifier' +import { notifySuccess, notifyFailure } from './utilities/notifier' const logger = remote.getGlobal('logger') @@ -128,7 +128,7 @@ function launchAuthWindow (token) { }) .catch((err) => { logger.error('Failed: ' + JSON.stringify(err.error)) - Notifier('Sync failed', 'Please check your network condition. 03') + notifyFailure('Sync failed', 'Please check your network condition. 03') }) } else if (error) { logger.error('Oops! Something went wrong and we couldn\'t' + @@ -355,12 +355,12 @@ function updateUserGists (userLoginId, token) { // clean up the snapshot for the previous state clearSyncSnapshot() - Notifier('Sync succeeds', humanReadableSyncTime) + notifySuccess('Sync succeeds', humanReadableSyncTime) reduxStore.dispatch(updateGistSyncStatus('DONE')) }) .catch(err => { - Notifier('Sync failed', 'Please check your network condition. 04') + notifyFailure('Sync failed', 'Please check your network condition. 04') logger.error('The request has failed: ' + err) reduxStore.dispatch(updateGistSyncStatus('DONE')) throw err @@ -411,7 +411,7 @@ function initUserSession (token) { logger.info('[Dispatch] updateUserSession INACTIVE') reduxStore.dispatch(updateUserSession({ activeStatus: 'INACTIVE' })) } - Notifier('Sync failed', 'Please check your network condition. 00') + notifyFailure('Sync failed', 'Please check your network condition. 00') }) } /** End: User session management **/ diff --git a/app/utilities/githubApi/index.js b/app/utilities/githubApi/index.js index 1c8626bf..aca76c0a 100644 --- a/app/utilities/githubApi/index.js +++ b/app/utilities/githubApi/index.js @@ -1,6 +1,6 @@ import { Promise } from 'bluebird' import { remote } from 'electron' -import Notifier from '../notifier' +import { notifyFailure } from '../notifier' import ProxyAgent from 'proxy-agent' import ReqPromise from 'request-promise' import Request from 'request' @@ -137,7 +137,7 @@ function getAllGistsV1 (token, userId) { .catch(err => { if (err !== EMPTY_PAGE_ERROR_MESSAGE) { logger.error(err) - Notifier('Sync failed', 'Please check your network condition. 05') + notifyFailure('Sync failed', 'Please check your network condition. 05') } }) .finally(() => {