Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #668 from RocketChat/release/1-11-0
Browse files Browse the repository at this point in the history
Release 1.11.0
  • Loading branch information
MartinSchoeler committed Dec 9, 2021
2 parents 6f70a8c + 116971f commit 3ecb6b8
Show file tree
Hide file tree
Showing 89 changed files with 46 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .loki/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
current
difference
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_danger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_nude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_secondary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_stack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Button_with_badge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Header_for_user_chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Header_with_custom_field.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Header_with_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Icons_doc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Icons_file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Icons_pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Icons_ppt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Icons_sheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Icons_zip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Menu_Item_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_Components_Menu_Item_with_icon.png
Binary file modified .loki/reference/chrome_Components_Modal_alert.png
Binary file modified .loki/reference/chrome_Components_Modal_animated.png
Binary file modified .loki/reference/chrome_Components_Modal_confirm.png
Binary file modified .loki/reference/chrome_Components_Modal_normal.png
Binary file modified .loki/reference/chrome_Components_Modal_timeout.png
Binary file modified .loki/reference/chrome_Components_Screen_with_agent.png
Binary file modified .loki/reference/chrome_Components_Screen_with_agent_email.png
Binary file modified .loki/reference/chrome_Components_Screen_with_agent_phone.png
Binary file modified .loki/reference/chrome_Forms_DateInput_default.png
Binary file modified .loki/reference/chrome_Forms_DateInput_disabled.png
Binary file modified .loki/reference/chrome_Forms_DateInput_filled.png
Binary file modified .loki/reference/chrome_Forms_DateInput_small.png
Binary file modified .loki/reference/chrome_Forms_DateInput_with_error.png
Binary file modified .loki/reference/chrome_Forms_Form_default.png
Binary file modified .loki/reference/chrome_Forms_PasswordInput_disabled.png
Binary file modified .loki/reference/chrome_Forms_SelectInput_disabled.png
Binary file modified .loki/reference/chrome_Forms_TextInput_disabled.png
Binary file modified .loki/reference/chrome_Messages_MessageBlocks_with_blocks.png
Binary file modified .loki/reference/chrome_Messages_MessageList_normal.png
Binary file modified .loki/reference/chrome_Messages_MessageList_with_typing_users.png
Binary file modified .loki/reference/chrome_Messages_Message_default.png
Binary file modified .loki/reference/chrome_Messages_Message_grouping.png
Binary file modified .loki/reference/chrome_Messages_Message_markdown.png
Binary file modified .loki/reference/chrome_Messages_Message_me.png
Binary file modified .loki/reference/chrome_Messages_Message_with_files_attachments.png
Binary file modified .loki/reference/chrome_Messages_Message_with_image_attachment.png
Binary file modified .loki/reference/chrome_Messages_Message_with_quotation.png
Binary file modified .loki/reference/chrome_Messages_TypingIndicator_with_avatars.png
Binary file modified .loki/reference/chrome_Routes_Chat_loading.png
Binary file modified .loki/reference/chrome_Routes_Chat_normal.png
Binary file modified .loki/reference/chrome_Routes_Chat_with_trigger_messages.png
Binary file modified .loki/reference/chrome_Routes_Chat_with_typing_user.png
Binary file modified .loki/reference/chrome_Routes_Leave_a_message_loading.png
Binary file modified .loki/reference/chrome_Routes_Register_loading.png
Binary file modified .loki/reference/chrome_Routes_SwitchDepartment_loading.png
Binary file modified .loki/reference/chrome_Routes_SwitchDepartment_normal.png
Binary file modified .loki/reference/chrome_Routes_TriggerMessage_multiple.png
Binary file modified .loki/reference/chrome_UiKit_Message_Actions_block_button.png
Binary file modified .loki/reference/chrome_UiKit_Message_Actions_block_datepicker.png
Binary file modified .loki/reference/chrome_UiKit_Message_Button_element_default.png
Binary file modified .loki/reference/chrome_UiKit_Message_Context_block_mrkdwn.png
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 1.11.0 - 2021-12-09
[NEW] Introduce clearLocalStorageWhenChatEnded setting logic (#666)
[IMPROVE] Change logic to generate token on Live Chat (#667)

## 1.10.0 - 2021-11-22
[NEW] Audio and Video calling in Livechat using WebRTC (#646)
[FIX] LoadConfig after registering guest (#640)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rocket.chat/livechat",
"version": "1.10.0",
"version": "1.11.0",
"files": [
"/build"
],
Expand Down Expand Up @@ -87,6 +87,7 @@
"@kossnocorp/desvg": "^0.2.0",
"@rocket.chat/sdk": "^1.0.0-alpha.42",
"@rocket.chat/ui-kit": "^0.14.1",
"crypto-js": "^4.1.1",
"css-vars-ponyfill": "^2.3.2",
"date-fns": "^2.15.0",
"desvg": "^1.0.2",
Expand Down
2 changes: 0 additions & 2 deletions src/components/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ export const setCookies = (rid, token) => {
document.cookie = `rc_room_type=l; path=/; ${ getSecureCookieSettings() }`;
};

export const createToken = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);

export const getAvatarUrl = (username) => (username ? `${ Livechat.client.host }/avatar/${ username }` : null);

export const msgTypesNotRendered = ['livechat_video_call', 'livechat_navigation_history', 'au', 'command', 'uj', 'ul', 'livechat-close'];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hooks.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Livechat } from '../api';
import { createToken } from '../components/helpers';
import { store } from '../store';
import CustomFields from './customFields';
import { setWidgetLanguage } from './locale';
import { loadConfig } from './main';
import { parentCall } from './parentCall';
import { createToken } from './random';
import Triggers from './triggers';

const createOrUpdateGuest = async (guest) => {
Expand Down
5 changes: 5 additions & 0 deletions src/lib/random.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

import * as crypto from 'crypto-js';

const UNMISTAKABLE_CHARS = '23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz';

const fraction = () => {
Expand All @@ -21,3 +24,5 @@ export const createRandomString = (charsCount, alphabet) =>

export const createRandomId = (charsCount = 17) =>
createRandomString(charsCount, UNMISTAKABLE_CHARS);

export const createToken = () => crypto.lib.WordArray.random(32).toString(crypto.enc.Hex);
15 changes: 12 additions & 3 deletions src/lib/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { route } from 'preact-router';

import { Livechat } from '../api';
import { CallStatus, isCallOngoing } from '../components/Calls/CallStatus';
import { setCookies, upsert, canRenderMessage, createToken } from '../components/helpers';
import { setCookies, upsert, canRenderMessage } from '../components/helpers';
import I18n from '../i18n';
import { store } from '../store';
import { store, initialState } from '../store';
import { normalizeAgent } from './api';
import Commands from './commands';
import constants from './constants';
import { loadConfig, processUnread } from './main';
import { parentCall } from './parentCall';
import { createToken } from './random';
import { normalizeMessage, normalizeMessages } from './threads';
import { handleTranscript } from './transcript';

Expand All @@ -21,6 +22,14 @@ export const closeChat = async ({ transcriptRequested } = {}) => {
await handleTranscript();
}

const { config: { settings: { clearLocalStorageWhenChatEnded } = {} } = {} } = store.state;

if (clearLocalStorageWhenChatEnded) {
// exclude UI-affecting flags
const { minimized, visible, undocked, expanded, ...initial } = initialState();
await store.setState(initial);
}

await loadConfig();
parentCall('callback', 'chat-ended');
route('/chat-finished');
Expand Down Expand Up @@ -127,7 +136,7 @@ const isAgentHidden = () => {

const transformAgentInformationOnMessage = (message) => {
const { user } = store.state;
if (message.u && message.u._id !== user._id && isAgentHidden()) {
if (message && user && message.u && message.u._id !== user._id && isAgentHidden()) {
return { ...message, u: { _id: message.u._id } };
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/threads.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Livechat } from '../api';
import { upsert, createToken } from '../components/helpers';
import { upsert } from '../components/helpers';
import { store } from '../store';
import { createToken } from './random';

const addParentMessage = async (parentMessage) => {
const { state } = store;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/triggers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { route } from 'preact-router';

import { Livechat } from '../api';
import { upsert, createToken, asyncForEach } from '../components/helpers';
import { upsert, asyncForEach } from '../components/helpers';
import store from '../store';
import { normalizeAgent } from './api';
import { processUnread } from './main';
import { parentCall } from './parentCall';
import { createToken } from './random';

const agentCacheExpiry = 3600000;
let agentPromise;
Expand Down
3 changes: 2 additions & 1 deletion src/routes/Chat/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { route } from 'preact-router';

import { Livechat } from '../../api';
import { ModalManager } from '../../components/Modal';
import { createToken, debounce, getAvatarUrl, canRenderMessage, throttle, upsert } from '../../components/helpers';
import { debounce, getAvatarUrl, canRenderMessage, throttle, upsert } from '../../components/helpers';
import I18n from '../../i18n';
import { normalizeQueueAlert } from '../../lib/api';
import constants from '../../lib/constants';
import { loadConfig } from '../../lib/main';
import { parentCall, runCallbackEventEmitter } from '../../lib/parentCall';
import { createToken } from '../../lib/random';
import { initRoom, closeChat, loadMessages, loadMoreMessages, defaultRoomParams, getGreetingMessages } from '../../lib/room';
import { Consumer } from '../../store';
import Chat from './component';
Expand Down
3 changes: 2 additions & 1 deletion src/routes/LeaveMessage/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { h, Component } from 'preact';

import { Livechat } from '../../api';
import { ModalManager } from '../../components/Modal';
import { createToken, parseOfflineMessage } from '../../components/helpers';
import { parseOfflineMessage } from '../../components/helpers';
import { parentCall } from '../../lib/parentCall';
import { createToken } from '../../lib/random';
import { Consumer } from '../../store';
import LeaveMessage from './component';

Expand Down
2 changes: 1 addition & 1 deletion src/routes/SwitchDepartment/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { h, Component } from 'preact';

import { Livechat } from '../../api';
import { ModalManager } from '../../components/Modal';
import { createToken } from '../../components/helpers';
import history from '../../history';
import I18n from '../../i18n';
import { loadConfig } from '../../lib/main';
import { createToken } from '../../lib/random';
import { Consumer } from '../../store';
import SwitchDepartment from './component';

Expand Down
3 changes: 2 additions & 1 deletion src/store/Store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mitt from 'mitt';

import { parentCall } from '../lib/parentCall';
import { createToken } from '../lib/random';

const { localStorage, sessionStorage } = window;

Expand Down Expand Up @@ -40,7 +41,7 @@ export default class Store {
});

window.addEventListener('load', () => {
const sessionId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
const sessionId = createToken();
sessionStorage.setItem('sessionId', sessionId);
const { openSessionIds = [] } = this._state;
this.setState({ openSessionIds: [sessionId, ...openSessionIds] });
Expand Down
9 changes: 4 additions & 5 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { h, Component, createContext } from 'preact';

import { createToken } from '../lib/random';
import Store from './Store';

const createToken = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);

const initialState = {
export const initialState = () => ({
token: createToken(),
typing: [],
config: {
Expand Down Expand Up @@ -36,10 +35,10 @@ const initialState = {
unread: null,
incomingCallAlert: null,
ongoingCall: null, // TODO: store call info like url, startTime, timeout, etc here
};
});

const dontPersist = ['messages', 'typing', 'loading', 'alerts', 'unread', 'noMoreMessages', 'modal', 'incomingCallAlert', 'ongoingCall'];
export const store = new Store(initialState, { dontPersist });
export const store = new Store(initialState(), { dontPersist });

if (process.env.NODE_ENV === 'development') {
store.on('change', ([, , partialState]) => {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5062,6 +5062,11 @@ crypto-browserify@^3.11.0:
randombytes "^2.0.0"
randomfill "^1.0.3"

crypto-js@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==

crypto-random-string@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"
Expand Down

0 comments on commit 3ecb6b8

Please sign in to comment.