Releases: vaadin/collaboration-kit
Vaadin Collaboration Engine 3.2.0.alpha2
Add PresenceManager
API to handle user presence in topics
The new PresenceManager
can now be used as a middle-layer API to handle user presence in topics: set the local-user presence, handle user presence changes and get the present users in a topic. This new API makes it easy to create custom components with collaboration features, for example a list of active users:
VerticalLayout users = new VerticalLayout();
PresenceManager presence = new PresenceManager(users, ownUserInfo, topicId);
presence.setAutoPresence(true);
presence.setNewUserHandler(newUserInfo -> {
Component card = createUserCard(newUserInfo);
users.add(card);
return () -> users.remove(card);
});
Related issue: #37
Other changes
3.2.0.alpha1
Add MessageConfigurator API to customize messages
Enables changing the properties of MessageListItem
after CollaborationMessageList
has generated them.
For example, theme variants can be added and removed to differentiate the current user's own messages from the others .
collaborationMessageList.setMessageConfigurator((message, user) -> {
if (user.equals(localUser)) {
message.addThemeNames("outbound");
}
});
Related issue: #30
Compatibility
This version is targeted for Vaadin 21, and will be included in the following Vaadin 21 pre-release.
Collaboration Engine 3.1.1
Fixed beacon problems when using Spring Security
Previous URL for the beacon (/beacon/) was being blocked by Spring security's CSRF filtering. That generated an internal redirect to the error page, which could make the error page be saved by the SavedRequestAwareAuthenticationSuccessHandler. This issue was fixed by changing the URL to use to the format used by Flow's internal requests, which should be not be blocked. (#41)
Collaboration Engine 3.1.0
What's new in 3.1
Collaboration Engine 3.1 introduced the Discuss feature, to create a chat with only a few lines of code by automatically synchronizing the messages for all users connected to the same topic. The implementation includes two components: CollaborationMessageList and CollaborationMessageInput.
Example to set it up:
User userEntity = userService.getCurrentUser();
UserInfo userInfo = new UserInfo(userEntity.getId(),
userEntity.getName(), userEntity.getImageUrl());
String topicId = "general";
CollaborationMessageList messageList = new CollaborationMessageList(
userInfo, topicId);
CollaborationMessageInput messageInput = new CollaborationMessageInput(
messageList);
layout.add(messageList, messageInput);
Support for Persistent Messages in Discussion Components
Messages added to a CollaborationMessageList
can be persisted on an external backend to retain them when the application restarts. You can set a CollaborationMessagePersister
on the list and implement your logic to e.g. save messages to a database.
CollaborationMessagePersister persister = CollaborationMessagePersister.fromCallbacks(
fetchQuery -> messageRepository
.findAllByTopicSince(fetchQuery.getTopicId(), fetchQuery.getSince())
.stream().map(entity -> new CollaborationMessage(
new UserInfo(entity.getAuthor().getId()),
entity.getText(),
entity.getTime()
)),
persistRequest -> {
CollaborationMessage message = persistRequest.getMessage();
MessageEntity entity = new MessageEntity(
message.getText(),
persistRequest.getTopicId(),
userRepository.findById(message.getUser().getId());
);
messageRepository.save(entity);
});
CollaborationMessageList list = new CollaborationMessageList(user, topic, persister);
Submitter API for custom input components
CollaborationMessageInput
is the provided component to submit messages to a CollaborationMessageList
. You can connect a custom component to submit to the message list and configure it via a CollaborationMessageSubmitter
which will be activated when the list connects to the topic.
CollaborationMessageList list = new CollaborationMessageList(user, topic);
TextField field = new TextField();
Button button = new Button("Send");
button.setEnabled(false);
list.setSubmitter(activationContext -> {
button.setEnabled(true);
Registration clickRegistration = button.addClickListener(event -> {
activationContext.appendMessage(field.getValue());
field.setValue("");
});
return () -> {
clickRegistration.remove();
button.setEnabled(false);
};
});
layout.add(list, field, button);
Other Noteworthy Changes Since 3.0
- Make Collaboration Engine OSGi compatible
CollaborationList
as a new low-level data type- Expiration timeout for
CollaborationBinder
- Configure Collaboration Engine by defining a subclass of
CollaborationEngineConfiguration
as a Spring or CDI bean. - Fixed field highlight inside
Dialog
. - Providing images as stream resources with
CollaborationMessageList::setImageProvider
. - Trying to use an inactive topic connection now throws an exception. Trying to subscribe to data changes or update the data in Collaboration Engine while the topic connection is not active does not work. Now this is explicitly forbidden by throwing an exception. This affects only the low-level API usage (
CollaborationEngine::openTopicConnection
) userInfo.setColorIndex(-1)
now means that the Collaboration Engine should manage the user's color index and keep it consistent across topics and components. -1 is now the default value for the color index.CollaborationEngine
has now a public method,getUserColorIndex(UserInfo userInfo)
. It returns the user's color index that is explicitly defined. When the color index is -1, it will assign a color index automatically. It is useful when you build custom collaborative experiences and want to user colors which are consistent with other features, likeCollaborationBinder
andCollaborationAvatarGroup
.
- Removed the Vaadin BOM, now the Flow dependencies are scoped as provided.
UserInfo
can now be created outside the UI thread.
Compatibility
This version is part of Vaadin 20, and will also be compatible with the upcoming Vaadin 14.7 release.
3.1.0.beta2
Fix Persister Skipping Messages Sent at the Same Timestamp
The user should implement CollaborationMessagePersister
to fetch messages which have been submitted from the timestamp provided by FetchQuery::getSince
. This is the timestamp of the last message that is already loaded. Previously it was expected that the persister implementation returns messages after this timestamp (message.getTime() > fetchQuery.getSince()
). This meant that if there are multiple messages submitted during the same millisecond, not all messages would be loaded. To fix this, now it's expected to include the messages at the getSince
timestamp (message.getTime() >= fetchQuery.getSince()
). The component will take care of filtering duplicates, which are expected when returning again the already loaded latest messages.
Compatibility
This version is targeted for Vaadin 20, and will be included in the following Vaadin 20 pre-release.
3.1.0.beta1
Keep Using the Persister Provided in Message List's Constructor
Previously CollaborationMessagePersister
was set together with the topic id of CollaborationMessageList
. When changing the topic id, you needed to provide the persister again, even if you always wanted to use the same instance. Now the persister can be set only in the component's constructor, and it will be used for the full lifecycle of the component. Different topics can be handled differently in the persister's implementation if needed.
Throw If Message Persister Ignores Query Properties
To make sure that your CollaborationMessagePersister
implementation uses all the required parameters for querying messages from your backend, the CollaborationMessageList
component throws an exception if the FetchQuery
's getters are not called. Previously this applied only to getSince
, now also to getTopicId
.
Compatibility
This version is targeted for Vaadin 20, and will be included in the following Vaadin 20 pre-release.
3.1.0.alpha7
Make Collaboration Engine OSGi compatible
Add Messages to the list of imported packages
Add CollaborationList.setExpirationTimeout(Instant)
Add similar low-level expiration timeouts to CollaborationList
, as what CollaborationMap
already has.
Compatibility
This version is targeted for Vaadin 20, and will be included in the following Vaadin 20 pre-release.
3.1.0.alpha6
Fail Early If Collaboration Message Persister Is Fetching Duplicate Messages
If your implementation of CollaborationMessagePersister
does not use the FetchQuery.getSince()
timestamp, an exception will be thrown. The timestamp is needed to fetch only the messages which have been submitted after the last fetched message, or otherwise CollaborationMessageList
will display duplicates.
Compatibility
This version is targeted for Vaadin 20, and will be included in the following Vaadin 20 pre-release.
3.1.0.alpha5
Support for Persistent Messages in Discussion Components
Messages added to a CollaborationMessageList
can now be persisted on an external backend to retain them when the application restarts. You can set a CollaborationMessagePersister
on the list and implement your logic to e.g. save messages to a database.
CollaborationMessagePersister persister = CollaborationMessagePersister.fromCallbacks(
fetchQuery -> messageRepository
.findAllByTopicSince(fetchQuery.getTopicId(), fetchQuery.getSince())
.stream().map(entity -> new CollaborationMessage(
new UserInfo(entity.getAuthor().getId()),
entity.getText(),
entity.getTime()
)),
persistRequest -> {
CollaborationMessage message = persistRequest.getMessage();
MessageEntity entity = new MessageEntity(
message.getText(),
persistRequest.getTopicId(),
userRepository.findById(message.getUser().getId());
);
messageRepository.save(entity);
});
CollaborationMessageList list = new CollaborationMessageList(user, topic, persister);
Submitter API for custom input components
CollaborationMessageInput
is the provided component to submit messages to a CollaborationMessageList
. Now you can connect a custom component to the list and configure it via a CollaborationMessageSubmitter
which will be activated when the list connects to the topic.
CollaborationMessageList list = new CollaborationMessageList(user, topic);
TextField field = new TextField();
Button button = new Button();
button.setEnabled(false);
list.setSubmitter(activationContext -> {
button.setEnabled(true);
Registration registration = button.addClickListener(event ->
activationContext.appendMessage(field.getValue()));
return () -> {
registration.remove();
button.setEnabled(false);
};
});
add(list, field, button);
New CollaborationList
CollaborationList
is a collaborative list of item you can obtain via TopicConnection::getNamedList
. The list supports getting its items, appending new ones, and subscribing to list changes:
CollaborationEngine.getInstance().openTopicConnection(this, "topic", user, connection -> {
CollaborationList list = connection.getNamedList("notifications");
list.subscribe(event -> {
event.getAddedItem(String.class).ifPresent(Notification::show);
});
return () -> {};
});
Other Changes
- Fixed field highlight inside
Dialog
. - Providing images as stream resources with
CollaborationMessageList::setImageProvider
. CollaborationMessageInput
now takesCollaborationMessageList
as a constructor argument.
Compatibility
This version is targeted for Vaadin 20, and will be included in the following Vaadin 20 pre-release.
3.1.0.alpha4
Real-Time Chat/Commenting Components
CollaborationMessageList
is a component that automatically displays all messages that are submitted to a particular topic. CollaborationMessageInput
is a component that enables submitting new messages to a topic. You can build real-time chat/commenting features to your app by adding these two components to the UI and connecting them to the same topic.
// User info will be used in the messages submitted by this user.
UserInfo user = new UserInfo(userId, userName, userImageUrl);
// Topic id can be considered as the identifier of a "chat room".
String topicId = "general";
// Component that displays messages posted to the topic:
CollaborationMessageList list = new CollaborationMessageList(user, topicId);
// Component that enables submitting new messages to the topic:
CollaborationMessageInput input = new CollaborationMessageInput(user, topicId);
// The rest is just building and styling the UI how you want.
VerticalLayout chatLayout = new VerticalLayout(list, input);
chatLayout.setHeight("500px");
chatLayout.setWidth("400px");
chatLayout.expand(list);
input.setWidthFull();
input.getStyle().set("flexShrink", "0");
add(chatLayout);
Other Changes
- The
CollaborationExampleComponent
prototype, which was included in earlier alpha versions, has been removed in favor of the new components. - Trying to use inactive topic connection throws now an exception. Trying to subscribe to data changes or update the data in Collaboration Engine while the topic connection is not active does not work. Now this is explicitly forbidden by throwing an exception. This affects only the low-level API usage (
CollaborationEngine.getInstance().openTopicConnection()
)
Compatibility
This version is targeted for Vaadin 20, and will be included in the following Vaadin 20 pre-release.