util: Import notifyError dynamically when needed

For unit tests, it is best not to pull in UI related code.

https://bugzilla.gnome.org/show_bug.cgi?id=783738

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3164>
This commit is contained in:
Sam Spilsbury 2017-06-14 00:43:20 +08:00 committed by Marge Bot
parent 6fd0aac864
commit 4711f6eee4

View File

@ -6,7 +6,6 @@ import Shell from 'gi://Shell';
import St from 'gi://St'; import St from 'gi://St';
import GnomeDesktop from 'gi://GnomeDesktop'; import GnomeDesktop from 'gi://GnomeDesktop';
import * as Main from '../ui/main.js';
import {formatTime} from './dateUtils.js'; import {formatTime} from './dateUtils.js';
// http://daringfireball.net/2010/07/improved_regex_for_matching_urls // http://daringfireball.net/2010/07/improved_regex_for_matching_urls
@ -184,8 +183,10 @@ export function trySpawnCommandLine(commandLine) {
} }
function _handleSpawnError(command, err) { function _handleSpawnError(command, err) {
let title = _('Execution of “%s” failed:').format(command); const title = _('Execution of “%s” failed:').format(command);
Main.notifyError(title, err.message); // Use dynamic import to not pull in UI related code in unit tests
import('../ui/main.js').then(
({notifyError}) => notifyError(title, err.message));
} }
/** /**