From 193febd18c67516bbd4e07a46537aa4e27ca6352 Mon Sep 17 00:00:00 2001 From: shelley vohr Date: Tue, 20 Feb 2018 23:30:32 -0500 Subject: [PATCH] deprecate boolean highlightMode param (#11993) * deprecate boolean highlightMode param * add process.noDeprecations check * fix native method override * add todo --- atom/browser/api/atom_api_tray.cc | 10 ++++++++++ lib/browser/api/tray.js | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index 701a5e9ac708..27d186e0d038 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -39,6 +39,16 @@ struct Converter { return true; } } + + bool highlight; + if (ConvertFromV8(isolate, val, &highlight)) { + if (highlight) + *out = atom::TrayIcon::HighlightMode::SELECTION; + else + *out = atom::TrayIcon::HighlightMode::NEVER; + return true; + } + return false; } }; diff --git a/lib/browser/api/tray.js b/lib/browser/api/tray.js index bc0a9d26f655..8f2ee5acd0af 100644 --- a/lib/browser/api/tray.js +++ b/lib/browser/api/tray.js @@ -1,6 +1,20 @@ const {EventEmitter} = require('events') +const {deprecate} = require('electron') const {Tray} = process.atomBinding('tray') Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype) +// TODO(codebytere): remove in 3.0 +const nativeSetHighlightMode = Tray.prototype.setHighlightMode +Tray.prototype.setHighlightMode = function (param) { + if (!process.noDeprecations && typeof param === 'boolean') { + if (param) { + deprecate.warn('tray.setHighlightMode(true)', `tray.setHighlightMode("on")`) + } else { + deprecate.warn('tray.setHighlightMode(false)', `tray.setHighlightMode("off")`) + } + } + return nativeSetHighlightMode.call(this, param) +} + module.exports = Tray