Commit 4c924a66 authored by JC Brand's avatar JC Brand

Split bookmarks plugin into headless and views

Fixes #1577
parent 0e49ebf6
...@@ -48,7 +48,7 @@ converse.plugins.add('converse-roomslist', { ...@@ -48,7 +48,7 @@ converse.plugins.add('converse-roomslist', {
comparator (room) { comparator (room) {
if (room.get('bookmarked')) { if (room.get('bookmarked')) {
const bookmark = _.head(_converse.bookmarksview.model.where({'jid': room.get('jid')})); const bookmark = _.head(_converse.bookmarks.where({'jid': room.get('jid')}));
return bookmark.get('name'); return bookmark.get('name');
} else { } else {
return room.get('name'); return room.get('name');
...@@ -139,8 +139,8 @@ converse.plugins.add('converse-roomslist', { ...@@ -139,8 +139,8 @@ converse.plugins.add('converse-roomslist', {
}, },
getRoomsListElementName () { getRoomsListElementName () {
if (this.model.get('bookmarked') && _converse.bookmarksview) { if (this.model.get('bookmarked') && _converse.bookmarks) {
const bookmark = _.head(_converse.bookmarksview.model.where({'jid': this.model.get('jid')})); const bookmark = _.head(_converse.bookmarks.where({'jid': this.model.get('jid')}));
return bookmark.get('name'); return bookmark.get('name');
} else { } else {
return this.model.get('name'); return this.model.get('name');
......
...@@ -8,8 +8,9 @@ import "@converse/headless/converse-mam"; // XEP-0313 Message Archiv ...@@ -8,8 +8,9 @@ import "@converse/headless/converse-mam"; // XEP-0313 Message Archiv
import "@converse/headless/converse-ping"; // XEP-0199 XMPP Ping import "@converse/headless/converse-ping"; // XEP-0199 XMPP Ping
import "@converse/headless/converse-pubsub"; // XEP-0060 PubSub import "@converse/headless/converse-pubsub"; // XEP-0060 PubSub
import "@converse/headless/converse-vcard"; // XEP-0054 VCard-temp import "@converse/headless/converse-vcard"; // XEP-0054 VCard-temp
import "@converse/headless/converse-bookmarks"; // XEP-0048 Bookmarks
import "converse-autocomplete"; import "converse-autocomplete";
import "converse-bookmarks"; // XEP-0048 Bookmarks import "converse-bookmark-views"; // Views for XEP-0048 Bookmarks
import "converse-chatview"; // Renders standalone chat boxes for single user chat import "converse-chatview"; // Renders standalone chat boxes for single user chat
import "converse-controlbox"; // The control box import "converse-controlbox"; // The control box
import "converse-dragresize"; // Allows chat boxes to be resized by dragging them import "converse-dragresize"; // Allows chat boxes to be resized by dragging them
...@@ -31,7 +32,7 @@ import converse from "@converse/headless/converse-core"; ...@@ -31,7 +32,7 @@ import converse from "@converse/headless/converse-core";
const WHITELISTED_PLUGINS = [ const WHITELISTED_PLUGINS = [
'converse-autocomplete', 'converse-autocomplete',
'converse-bookmarks', 'converse-bookmark-views',
'converse-chatboxviews', 'converse-chatboxviews',
'converse-chatview', 'converse-chatview',
'converse-controlbox', 'converse-controlbox',
......
// Converse.js (A browser based XMPP chat client) // Converse.js (A browser based XMPP chat client)
// https://conversejs.org // https://conversejs.org
// //
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2019, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
// //
/*global define */ /*global define */
...@@ -65,6 +65,8 @@ converse.plugins.add('converse-bookmarks', { ...@@ -65,6 +65,8 @@ converse.plugins.add('converse-bookmarks', {
allow_public_bookmarks: false allow_public_bookmarks: false
}); });
_converse.api.promises.add('bookmarksInitialized');
/** /**
* Check if the user has a bookmark with a saved nickanme * Check if the user has a bookmark with a saved nickanme
* for this groupchat and return it. * for this groupchat and return it.
...@@ -72,7 +74,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -72,7 +74,7 @@ converse.plugins.add('converse-bookmarks', {
* @method _converse#getNicknameFromBookmark * @method _converse#getNicknameFromBookmark
*/ */
_converse.getNicknameFromBookmark = function (jid) { _converse.getNicknameFromBookmark = function (jid) {
if (_converse.bookmarks || !_converse.allow_bookmarks) { if (!_converse.bookmarks || !_converse.allow_bookmarks) {
return null; return null;
} }
const bookmark = _converse.bookmarks.findWhere({'jid': jid}); const bookmark = _converse.bookmarks.findWhere({'jid': jid});
......
...@@ -86,6 +86,7 @@ pluggable.enable(_converse, '_converse', 'pluggable'); ...@@ -86,6 +86,7 @@ pluggable.enable(_converse, '_converse', 'pluggable');
// These are just the @converse/headless plugins, for the full converse, // These are just the @converse/headless plugins, for the full converse,
// the other plugins are whitelisted in src/converse.js // the other plugins are whitelisted in src/converse.js
_converse.core_plugins = [ _converse.core_plugins = [
'converse-bookmarks',
'converse-caps', 'converse-caps',
'converse-chatboxes', 'converse-chatboxes',
'converse-disco', 'converse-disco',
...@@ -352,7 +353,7 @@ function initPlugins() { ...@@ -352,7 +353,7 @@ function initPlugins() {
{'_converse': _converse}, {'_converse': _converse},
whitelist, _converse.blacklisted_plugins whitelist, _converse.blacklisted_plugins
); );
/** /**
* Triggered once all plugins have been initialized. This is a useful event if you want to * Triggered once all plugins have been initialized. This is a useful event if you want to
* register event handlers but would like your own handlers to be overridable by * register event handlers but would like your own handlers to be overridable by
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* Any of the following components may be removed if they're not needed. * Any of the following components may be removed if they're not needed.
*/ */
import "./converse-pubsub"; // XEP-0199 XMPP Ping import "./converse-pubsub"; // XEP-0199 XMPP Ping
import "./converse-bookmarks"; // XEP-0199 XMPP Ping
import "./converse-chatboxes"; // Backbone Collection and Models for chat boxes import "./converse-chatboxes"; // Backbone Collection and Models for chat boxes
import "./converse-disco"; // Service discovery plugin import "./converse-disco"; // Service discovery plugin
import "./converse-mam"; // XEP-0313 Message Archive Management import "./converse-mam"; // XEP-0313 Message Archive Management
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment