Fix bookmark

jh-changes
Shin'ya Ueoka 7 years ago
parent d41c7476a6
commit 53c3ddab2e
  1. 16
      src/background/actions/command.js

@ -1,3 +1,4 @@
import messages from 'shared/messages';
import actions from '../actions'; import actions from '../actions';
import * as tabs from '../shared/tabs'; import * as tabs from '../shared/tabs';
import * as bookmarks from '../shared/bookmarks'; import * as bookmarks from '../shared/bookmarks';
@ -45,7 +46,7 @@ const addBookmarkCommand = (tab, args) => {
return Promise.resolve(); return Promise.resolve();
} }
return bookmarks.create(args[0], tab.url); return bookmarks.create(args.join(' '), tab.url);
}; };
const setCommand = (args) => { const setCommand = (args) => {
@ -78,7 +79,18 @@ const exec = (tab, line, settings) => {
case 'buffer': case 'buffer':
return bufferCommand(args); return bufferCommand(args);
case 'addbookmark': case 'addbookmark':
return addBookmarkCommand(tab, args); return addBookmarkCommand(tab, args).then((item) => {
if (!item) {
return browser.tabs.sendMessage(tab.id, {
type: messages.CONSOLE_SHOW_ERROR,
text: 'Could not create a bookmark',
});
}
return browser.tabs.sendMessage(tab.id, {
type: messages.CONSOLE_SHOW_INFO,
text: 'Saved current page: ' + item.url,
});
});
case 'set': case 'set':
return setCommand(args); return setCommand(args);
case '': case '':