Commit Graph

62 Commits

Author SHA1 Message Date
JC Brand
bf4b3efa5b Import _converse and api 2020-05-18 10:54:37 +02:00
JC Brand
e621362471 mam: include chatbox in data sent via MAMResult 2020-05-06 18:01:59 +02:00
JC Brand
b5eea12d49 Refactor so that message attributes are parsed early
It's better to parse an incoming message stanza early, than to have
all kinds of methods throughout the codebase that does querySelector
etc.

Firstly, it allows us to catch and report errors and malicious stanzas early on.
It also simplifies programming because you don't need to try and
remember how to properly parse a stanza, all the work is done upfront
for you.
2020-04-27 16:34:37 +02:00
JC Brand
c6f8ef0c46 Various JSDoc related fixes and improvements
Using the `@method` directive on a `@class` means that the method
doesn't appear.
2020-04-23 13:55:08 +02:00
JC Brand
b44c0c266c mam: Add MAMResult hook 2020-04-23 13:55:08 +02:00
JC Brand
7e2552bd8c core: Allow multiple imports 2020-04-23 13:50:35 +02:00
JC Brand
c4c7e41981 MAM: better error logging 2020-04-10 16:04:46 +02:00
JC Brand
030c26a8ab Use api shortcut instead of _converse.api 2020-03-31 13:16:24 +02:00
JC Brand
631b9bb438 Use the settings API for setting and getting config settings
This is an initial step towards no longer storing and accessing settings
directly via the `_converse` object
2020-03-31 11:57:03 +02:00
JC Brand
a7f28cd61d When creating message objects, wait for confirmation from storage
Queue messages and handle them sequentially, each time waiting for promises to
resolve before handling the next message.

Updates #1899, which likely happens because an error message is received
before messages have been fetched.
2020-03-04 15:14:57 +01:00
JC Brand
0137eb88ae Smacks: Handle MUC messages received before the MUC exists 2020-02-19 13:39:07 +01:00
JC Brand
fb9fe280ac Updates to how dupes are detected.
- Collapse 3 different loops into one.
- Check all saved stanza ids in the parsed attrs, not just the archive id
- Remove check for archive id in converse-mam since it just duplicates what's now being done in converse-chat
- Don't use disco to check for support, XEP-359 mandates that services SHOULD advertise support,
  which is not a strong enough guarantee that they do.

updates #1856
2020-02-07 12:35:45 +01:00
JC Brand
f78837cbc5 Refactor identification of duplicates...
to rely on the parsed stanza attributes

This was to fix a bug whereby a full stanza was used to query for 1:1
messages with a full JID when the bare JID is stored.

We now are sure that the attributes we're using to query for duplicates
are the same attributes that get saved for a messages.
2020-02-03 23:24:44 +01:00
JC Brand
11e219dd41 Update copyright 2020-01-30 17:36:55 +01:00
Yaskhan
1653c1ae92 Update converse-mam.js
I think why do not come archives from group chats, and it turns out that you need to add "groupchat" in options. I spent half an hour searching in the documentation, and half an hour searching in the convers tests. And finally found in tests.
2019-12-26 15:56:04 +02:00
JC Brand
8b6c902c4c Set VCards via events, thereby reducing coupling
- Rename `chatRoomOpened` event to `chatRoomViewInitialized`
- Rename `chatBoxInitialized` to `chatBoxViewInitialized` and trigger only for `ChatBoxView` instances.
- New event `headlinesBoxViewInitialized`
- Trigger the `chatBoxInitialized` event when a new `_converse.ChatBox` is opened.
2019-12-18 15:20:51 +01:00
JC Brand
a4567ee075 muc: Store connection_status in session storage
Otherwise we might run into a situation where a very old,
cached MUC that's being restored has `connection_status` set to ENTERED
(and the user happens to be in the MUC via another client)
and then restores cached messages without taking
`clear_messages_on_reconnection` into account.
2019-12-11 08:10:27 +01:00
JC Brand
1c116b0385 mam: distinguish between messages fetched before and after MUC join 2019-11-29 16:17:48 +01:00
JC Brand
d7d810ba89 Improvements to rendering MUC MAM logs before joining
- Add config variable `muc_show_logs_before_join`
- Restore nickname form for the original use-case (when not showing MAM logs before joining).
- Render nickname form in the `.muc-bottom-panel` when showing MAM logs (instead of in a modal)
- Show a message when there aren't any archived messages to show
- Fix converse-mam so that chat logs are properly fetched before entering a MUC

closes #1266
2019-11-29 09:23:15 +01:00
JC Brand
b4dafcc45b Add support for XEP-0424 and XEP-0425
- Add support for switching ephemerality after message creation
- Move more methods from ChatBox and ChatRoom to utils/stanza.js
- Rename 'ephemeral' to 'is_ephemeral' since it's a boolean
2019-11-22 13:50:36 +01:00
JC Brand
8523cae8d0 Move message parsing code out of ChatBox into new stanza-utils plugin 2019-11-22 13:50:36 +01:00
JC Brand
caadb24310 Refactor logging out into its own module
So that we don't need to `_converse` obj in order to log messages
2019-11-22 13:50:36 +01:00
JC Brand
879e165ae5 Refactoring
- Move headless one-on-one chat functionality into converse-chat
- Split converse-headline into converse-headlines and converse-headlines-views
- Add api in `_converse.api.chatboxes` for creating chatboxes
- Add `_converse.api.controlbox.get` method
2019-11-04 15:05:50 +01:00
JC Brand
1fa203c990 Support for IndexedDB. updates #1105
Depend on latest backbone.browserStorage which has support for IndexedDB
via localforage.

Storage operations are now asynchronous and transactional.

Bugs fixed (mostly by waiting for operations to complete):

* Rooms are now fetched asynchronously, so wait before triggering `show`
  or when closing.
* Make sure chat create/update transactions complete before firing events
* Make sure chats and messages have been fetched before creating new ones.
* When doing a `fetch` with `wait: false` on a collection and then
  creating a model in that collection, then once the read
  operation finishes (after creating the model), the collection is emptied again.
* Patch and wait when saving.
  Otherwise we have previously set attributes overriding later ones.
* Make sure api.roomviews.close returns a promise

Test fixes:

* Chats are now asynchronously returned, so we need to use `await`
* Wait for the storage transaction to complete when creating and updating messages
* Wait for all chatboxes to close
    Otherwise we get sessionStorage inconsistencies due to the async nature of localforage.
* Wait for room views to close in spec/chatroom.js

In the process, remove the `closeAllChatBoxes` override in
converse-controlbox by letting the `close` method decide whether it
should be closed or not.
2019-10-30 13:02:23 +01:00
JC Brand
54e9c51a1a Don't rely on getUniqueId of Strophe.Connection
since we can't assume it's always available.
2019-10-11 17:46:13 +02:00
JC Brand
8780f7a128 Fix linting errors (no-unused-vars) 2019-10-09 16:27:58 +02:00
Christoph Scholz
cd5dacbe29 Process stanzas from mam one-by-one 2019-09-21 13:26:36 +02:00
JC Brand
35e97c2353 Ignore MAM chat messages not sent from yourself 2019-09-11 14:18:21 +02:00
JC Brand
89ac4a6969 Show error message with option to retry when MAM query times out 2019-08-13 11:08:03 +02:00
JC Brand
02e50ca3a3 converse-mam: Don't fetch MUC MAM messages on chatReconnected event
By this time the cached messages are not yet fetched, causing the entire
MAM archive to be queried.
2019-08-10 14:12:20 +02:00
JC Brand
5cb5ec4640 Fixes #1668. MUC MAM blocked by "info" messages 2019-08-06 23:30:02 +02:00
JC Brand
7bfb172f6e Updates #1548. MAM paging improvements.
* Explicit forwards and backwards paging
* Include upper or lower bound when calling `RSM.prototype.next` or `RSM.prototype.previous`
* Bugfix: Don't override new RSM parameters (caused infinite recursion)
2019-08-06 22:54:51 +02:00
JC Brand
8a9a0a4b19 Add support for paging through MAM results when catching up
Fixes #1548
2019-08-03 21:44:02 +02:00
JC Brand
c038794fb5 converse-mam: Light refactoring and cleanup 2019-08-03 21:43:06 +02:00
JC Brand
f12c024b99 Don't query MAM upon every page load.
Instead we should only query for newly created chats.
2019-07-29 15:41:03 +02:00
JC Brand
e20b654876 Stop using _.isUndefined 2019-07-29 10:32:29 +02:00
JC Brand
d95a7987ce Fix linting errors and add @module jsdoc directives 2019-07-11 10:48:52 +02:00
JC Brand
996a43792e converse-mam depends on converse-rsm 2019-06-20 16:51:50 +02:00
JC Brand
aece956281 Refactor strophe usage
- Upgrade to latest commit in Strophe
- Import individual Strophe dependencies
- Replace strophe plugins with code in Converse
2019-05-29 18:27:34 +02:00
JC Brand
7a18f59f8f Simplify rendering of trimmed chats
Also fix issue where trimmed headline chatboxes don't show the proper
color
2019-05-29 13:28:45 +02:00
JC Brand
1ef29bee4e Use composition instead of overrides 2019-05-24 16:02:07 +02:00
JC Brand
7032ded53f cleanup 2019-05-22 19:45:00 +02:00
JC Brand
7ab59ad63e Refactor MAM and clear private chats upon reconnection
- Add `onReconnected` method for chatboxes to clear messages
- Move MAM models to headless build.
- New event `onChatReconnected`
2019-05-22 14:10:19 +02:00
JC Brand
2526d80464 Change api.disco.supports to resolve to a Boolean
Also add a new API method `api.disco.features.get` for the use-case
where you still want the feature object to be returned.
2019-05-07 10:27:25 +02:00
JC Brand
c3dac272f8 Replace moment with DayJS 2019-05-06 14:27:18 +02:00
JC Brand
9528276be2 Use native Date methods instead of moment
- Use native `getTime` method instead of moment's `valueOf`
- Use toISOString() instead of moment().format()
  This makes the code timezone independent since we're now globally using UTC.
2019-05-06 10:28:03 +02:00
JC Brand
15b2273631 _converse.api.archive.query now returns a Promise
instead of accepting a callback functions.
2019-05-03 19:47:49 +02:00
JC Brand
ba6de8844e Use Object.keys instead of _.keys 2019-04-29 09:29:40 +02:00
JC Brand
34469425d6 Use Object.assign instead of _.extend 2019-04-29 09:07:15 +02:00
JC Brand
d41a7a14c3 Use API to emit and listen to events 2019-03-29 14:16:07 +01:00