From 34a4a70ae21cbe08da7f26f03bca48f39e28e552 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 30 Sep 2022 16:10:35 +0200 Subject: [PATCH] Move bookmarks into a modal --- CHANGES.md | 2 + docs/source/configuration.rst | 16 --- .../{form.js => components/bookmark-form.js} | 0 .../{ => components}/bookmarks-list.js | 17 +-- .../{ => components}/templates/form.js | 0 .../{ => components}/templates/item.js | 6 +- .../components/templates/list.js | 35 ++++++ src/plugins/bookmark-views/index.js | 6 +- src/plugins/bookmark-views/mixins.js | 1 - .../{modal.js => modals/bookmark-form.js} | 2 +- .../bookmark-views/modals/bookmark-list.js | 18 +++ .../bookmark-views/styles/bookmarks.scss | 6 + src/plugins/bookmark-views/templates/list.js | 32 ------ .../bookmark-views/tests/bookmarks-list.js | 108 ++++++------------ src/plugins/bookmark-views/tests/bookmarks.js | 37 ------ src/plugins/bookmark-views/utils.js | 1 - .../controlbox/templates/controlbox.js | 5 +- src/plugins/roomslist/templates/roomslist.js | 25 ++-- src/plugins/roomslist/view.js | 3 +- src/shared/styles/forms.scss | 16 +-- 20 files changed, 140 insertions(+), 196 deletions(-) rename src/plugins/bookmark-views/{form.js => components/bookmark-form.js} (100%) rename src/plugins/bookmark-views/{ => components}/bookmarks-list.js (78%) rename src/plugins/bookmark-views/{ => components}/templates/form.js (100%) rename src/plugins/bookmark-views/{ => components}/templates/item.js (69%) create mode 100644 src/plugins/bookmark-views/components/templates/list.js rename src/plugins/bookmark-views/{modal.js => modals/bookmark-form.js} (93%) create mode 100644 src/plugins/bookmark-views/modals/bookmark-list.js delete mode 100644 src/plugins/bookmark-views/templates/list.js diff --git a/CHANGES.md b/CHANGES.md index 894b06644..f817d7ea1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ - Update `nick` attribute on ChatRoom when user nickname changes - Restrict editing of MUC messages to ones with the same XEP-0421 occupant ID - Remove unfurls for links removed in a subsequent message correction +- Bookmarks now appear in a modal and the `hide_open_bookmarks` config setting has been removed. - #1004: Stop using fonts to render icons and use SVG instead - #2797: Weird unicode characters rendering outside of line-height - #2870: Fix for multiple URLs to be linkified when sent together in chat and adds a test for this. @@ -22,6 +23,7 @@ - #3007: Fix links becoming text when a message is edited - #3018: Fix MUC icons not functioning. + ## 9.1.1 (2022-05-05) - GIFs don't render inside unfurls and cause a TypeError diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index afe7901d2..d0b469d2e 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -962,22 +962,6 @@ hide_offline_users If set to ``true``, then offline users aren't shown in the roster. -hide_open_bookmarks -------------------- - -* Default: ``false`` (``true`` when the `view_mode`_ is set to ``fullscreen``). - -This setting applies to the ``converse-bookmarks`` plugin and specfically the -list of bookmarks shown in the ``Rooms`` tab of the control box. - -By default all bookmarks are shown in that list, if this setting is set to -``true``, then only bookmarks for rooms not currently open (i.e. that the -current user hasn't joined), are shown. - -Makes sense to set this to ``true`` when also using the non-core -``converse-roomslist`` plugin, which shows a list of currently open (i.e. -"joined") rooms. - .. _`i18n`: i18n diff --git a/src/plugins/bookmark-views/form.js b/src/plugins/bookmark-views/components/bookmark-form.js similarity index 100% rename from src/plugins/bookmark-views/form.js rename to src/plugins/bookmark-views/components/bookmark-form.js diff --git a/src/plugins/bookmark-views/bookmarks-list.js b/src/plugins/bookmark-views/components/bookmarks-list.js similarity index 78% rename from src/plugins/bookmark-views/bookmarks-list.js rename to src/plugins/bookmark-views/components/bookmarks-list.js index 68b493eea..87bcbb44d 100644 --- a/src/plugins/bookmark-views/bookmarks-list.js +++ b/src/plugins/bookmark-views/components/bookmarks-list.js @@ -1,8 +1,12 @@ +import debounce from "lodash-es/debounce"; import tpl_bookmarks_list from './templates/list.js'; +import tpl_spinner from "templates/spinner.js"; import { CustomElement } from 'shared/components/element.js'; import { _converse, api } from '@converse/headless/core.js'; import { initStorage } from '@converse/headless/utils/storage.js'; +import '../styles/bookmarks.scss'; + export default class BookmarksView extends CustomElement { @@ -10,6 +14,8 @@ export default class BookmarksView extends CustomElement { await api.waitUntil('bookmarksInitialized'); const { bookmarks, chatboxes } = _converse; + this.liveFilter = debounce((ev) => this.model.set({'filter_text': ev.target.value}), 100); + this.listenTo(bookmarks, 'add', () => this.requestUpdate()); this.listenTo(bookmarks, 'remove', () => this.requestUpdate()); @@ -29,15 +35,12 @@ export default class BookmarksView extends CustomElement { } render () { - return _converse.bookmarks && this.model ? tpl_bookmarks_list(this) : ''; + return _converse.bookmarks && this.model ? tpl_bookmarks_list(this) : tpl_spinner(); } - toggleBookmarksList (ev) { - ev?.preventDefault?.(); - const { CLOSED, OPENED } = _converse; - this.model.save({ - 'toggle-state': this.model.get('toggle-state') === CLOSED ? OPENED : CLOSED - }); + clearFilter (ev) { + ev?.stopPropagation?.(); + this.model.set('filter_text', ''); } } diff --git a/src/plugins/bookmark-views/templates/form.js b/src/plugins/bookmark-views/components/templates/form.js similarity index 100% rename from src/plugins/bookmark-views/templates/form.js rename to src/plugins/bookmark-views/components/templates/form.js diff --git a/src/plugins/bookmark-views/templates/item.js b/src/plugins/bookmark-views/components/templates/item.js similarity index 69% rename from src/plugins/bookmark-views/templates/item.js rename to src/plugins/bookmark-views/components/templates/item.js index 4a1380ac7..35cb566ff 100644 --- a/src/plugins/bookmark-views/templates/item.js +++ b/src/plugins/bookmark-views/components/templates/item.js @@ -1,15 +1,13 @@ import { __ } from 'i18n'; -import { _converse, api } from '@converse/headless/core.js'; import { html } from "lit"; -import { openRoomViaEvent, removeBookmarkViaEvent } from '../utils.js'; +import { openRoomViaEvent, removeBookmarkViaEvent } from '../../utils.js'; export default (bm) => { const jid = bm.get('jid'); - const is_hidden = !!(api.settings.get('hide_open_bookmarks') && _converse.chatboxes.get(jid)); const info_remove_bookmark = __('Unbookmark this groupchat'); const open_title = __('Click to open this groupchat'); return html` -