Skip to content

Commit

Permalink
fix(SUP-34892): When users send private messages their names appears …
Browse files Browse the repository at this point in the history
…incorrect in WC app. (#312)

* fix(SUP-34892): upd logic of generation user id

* fix(SUP-34892): reset user id

* fix(SUP-34892): upd common repo

* fix(SUP-34892): upd kaltura-cuepoint dependency
  • Loading branch information
semarche-kaltura authored Mar 14, 2023
1 parent 275c3b4 commit f509aa0
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"webpack-dev-server": "^4.9.0"
},
"dependencies": {
"@playkit-js/common": "^1.1.1",
"@playkit-js/common": "^1.1.5",
"@playkit-js/playkit-js-ui": "^0.73.0",
"@playkit-js/ui-managers": "^1.3.2",
"classnames": "^2.2.6"
Expand Down Expand Up @@ -99,7 +99,7 @@
"kaltura": {
"name": "qna",
"dependencies": {
"playkit-kaltura-cuepoints": "3.0.3",
"playkit-kaltura-cuepoints": "3.0.4",
"playkit-ui-managers": "1.3.4"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/announcementsAdapter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ToastSeverity} from '@playkit-js/common';
import {ToastSeverity} from '@playkit-js/common/dist/ui-common/toast-manager';
import {KitchenSinkMessages} from './kitchenSinkMessages';
import {MessageState, QnaMessage, QnaMessageType} from './qnaMessageFactory';
import {ToastIcon, ToastsType} from './components/toast-icon';
Expand Down
3 changes: 2 additions & 1 deletion src/aoaAdapter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {KitchenSinkMessages} from './kitchenSinkMessages';
import {BannerManager, ToastSeverity, VisibilityMode, BannerState} from '@playkit-js/common';
import {BannerManager, VisibilityMode, BannerState} from '@playkit-js/common/dist/ui-common/banner-manager';
import {ToastSeverity} from '@playkit-js/common/dist/ui-common/toast-manager';
import {MessageState, QnaMessage, QnaMessageType} from './qnaMessageFactory';
import {ToastIcon, ToastsType} from './components/toast-icon';
import {h} from 'preact';
Expand Down
12 changes: 8 additions & 4 deletions src/chatMessagesAdapter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {h} from 'preact';
import {ToastSeverity, generateId, getUserId} from '@playkit-js/common';
import {ToastSeverity} from '@playkit-js/common/dist/ui-common/toast-manager';
import {generateId} from '@playkit-js/common/dist/utils-common/utils';
import {KitchenSinkMessages} from './kitchenSinkMessages';
import {MessageDeliveryStatus, QnaMessage, QnaMessageFactory, QnaMessageType} from './qnaMessageFactory';
import {Utils} from './utils';
Expand All @@ -16,6 +17,7 @@ export interface ChatMessagesAdapterOptions {
displayToast: DisplayToast;
player: KalturaPlayerTypes.Player;
logger: KalturaPlayerTypes.Logger;
userId: string;
}

interface SubmitRequestParams {
Expand All @@ -32,6 +34,7 @@ export class ChatMessagesAdapter {
private _player: KalturaPlayerTypes.Player;
private _logger: KalturaPlayerTypes.Logger;

private _userId: string | undefined;
private _entryId: string | undefined;
private _metadataProfileId: number | null = null;

Expand All @@ -43,6 +46,7 @@ export class ChatMessagesAdapter {
this._player = options.player;
this._logger = options.logger;
options.setDataListener(this._handleTimedMetadata);
this._userId = options.userId;
}

private _handleTimedMetadata = ({payload}: TimedMetadataEvent): void => {
Expand All @@ -64,6 +68,7 @@ export class ChatMessagesAdapter {
public reset(): void {
this._metadataProfileId = null;
this._entryId = undefined;
this._userId = undefined;
}

public onMessageRead = (messageId: string): void => {
Expand Down Expand Up @@ -166,11 +171,10 @@ export class ChatMessagesAdapter {
};

private _prepareSubmitRequest(uuid: string, question: string, parentId: string | null) {
const userId = getUserId();
if (!this._entryId) {
throw new Error("Can't make requests without entryId");
}
if (!userId) {
if (!this._userId) {
throw new Error("Can't make requests without userId");
}
const missingProfileId = !this._metadataProfileId;
Expand Down Expand Up @@ -216,7 +220,7 @@ export class ChatMessagesAdapter {
metadata.ThreadId = thread.id;
}
metadata.Type = QnaMessageType.Question;
metadata.ThreadCreatorId = userId;
metadata.ThreadCreatorId = this._userId;
const xmlData = Utils.createXmlFromObject(metadata);

let metadataProfileId: number | string = this._metadataProfileId ? this._metadataProfileId : 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {h, Component} from 'preact';
import {A11yWrapper} from '@playkit-js/common';
import {A11yWrapper} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import * as styles from './autoExpandTextArea.scss';
import classNames from 'classnames';
import {PrivateIcon} from '../icons/private-icon';
Expand Down
2 changes: 1 addition & 1 deletion src/components/kitchen-sink/kitchenSink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, h} from 'preact';
import {A11yWrapper, OnClick} from '@playkit-js/common';
import {A11yWrapper, OnClick} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import * as styles from './kitchenSink.scss';
import {QnaMessage, QnaMessageType} from '../../qnaMessageFactory';
import {Thread} from '../thread';
Expand Down
2 changes: 1 addition & 1 deletion src/components/plugin-button/pluginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {h} from 'preact';
import * as styles from './pluginButton.scss';
import {ui} from 'kaltura-player-js';
import {A11yWrapper, OnClick} from '@playkit-js/common';
import {A11yWrapper, OnClick} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import {icons} from '../icons';

const {Tooltip, Icon} = KalturaPlayer.ui.components;
Expand Down
2 changes: 1 addition & 1 deletion src/components/scroll-down-button/scrollDownButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, h} from 'preact';
import {A11yWrapper} from '@playkit-js/common';
import {A11yWrapper} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import * as styles from './scrollDownButton.scss';
import {DownIcon} from './down-icon';

Expand Down
2 changes: 1 addition & 1 deletion src/components/thread/thread.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, h} from 'preact';
import {A11yWrapper} from '@playkit-js/common';
import {A11yWrapper} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import * as styles from './thread.scss';
import {MessageDeliveryStatus, QnaMessage, QnaMessageType} from '../../qnaMessageFactory';
import {TimeDisplay} from '../time-display';
Expand Down
4 changes: 2 additions & 2 deletions src/components/trimmed-text/trimmedText.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {h, Component} from 'preact';
import {A11yWrapper} from '@playkit-js/common';
import {A11yWrapper} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import {LinkifyString} from '@playkit-js/common/dist/ui-common/linkify-string';
import * as styles from './trimmedText.scss';
import {LinkifyString} from '@playkit-js/common';
import {Utils} from '../../utils';

interface TrimmedTextProps {
Expand Down
2 changes: 1 addition & 1 deletion src/kitchenSinkMessages.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MessageDeliveryStatus, QnaMessage } from "./qnaMessageFactory";
import { Utils } from "./utils";
import { EventsManager } from "@playkit-js/common";
import { EventsManager } from "@playkit-js/common/dist/ui-common/events-manager";

export enum KitchenSinkPluginEventTypes {
MessagesUpdatedEvent = "MessagesUpdatedEvent"
Expand Down
9 changes: 6 additions & 3 deletions src/qna-plugin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {h, ComponentChild} from 'preact';
import {ContribServices, ToastSeverity} from '@playkit-js/common';
import {OnClickEvent} from '@playkit-js/common';
import {ToastSeverity} from '@playkit-js/common/dist/ui-common/toast-manager';
import {ContribServices} from '@playkit-js/common/dist/ui-common/contrib-services';
import {getQnaUserId} from '@playkit-js/common/dist/utils-common/utils';
import {OnClickEvent} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import {UpperBarManager, SidePanelsManager} from '@playkit-js/ui-managers';
import {KitchenSink} from './components/kitchen-sink';
import {QnaPluginButton} from './components/plugin-button';
Expand Down Expand Up @@ -132,7 +134,8 @@ export class QnaPlugin extends KalturaPlayer.core.BasePlugin {
// TODO: move filterFn from ChatMessagesAdapter here
isKitchenSinkActive: this._isPluginActive,
updateMenuIcon: this._updateMenuIcon,
displayToast: this._displayToast
displayToast: this._displayToast,
userId: getQnaUserId(this._player)
});
// register to kitchenSink updated qnaMessages array
this._kitchenSinkMessages!.on(KitchenSinkPluginEventTypes.MessagesUpdatedEvent, this._onQnaMessage);
Expand Down
2 changes: 2 additions & 0 deletions src/types/qna-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export interface QnaPluginConfig {
expandMode: string;
position: string;
expandOnFirstPlay: boolean;
userId?: string;
userRole?: string;
}
14 changes: 10 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,13 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@playkit-js/common@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@playkit-js/common/-/common-1.1.1.tgz#b0c21e96794dd66622c1bbcfdf0373aad2b9f5dc"
integrity sha512-75l2CogQtpLggXp/FxjNsPbV+FKZ1MxhhLJolBwJYsKV/tyd61aKcbU81EzcyyVefkxYEcLdt2YrkFW64isTKw==
"@playkit-js/common@^1.1.5":
version "1.1.5"
resolved "https://registry.yarnpkg.com/@playkit-js/common/-/common-1.1.5.tgz#20410ef8e32c4820146a2a462d5318fac6be1e96"
integrity sha512-NgVELo6z9+DI9aiKL8oj5p/d5pzJCZgwuk0LN3lKizPuNfvu/30lavsH4hNCrWOjgnT7o4EEFrmVK9buzqmIHQ==
dependencies:
"@playkit-js/playkit-js-ui" "^0.74.0"
classnames "^2.3.2"
linkify-it "^4.0.1"

"@playkit-js/[email protected]":
Expand Down Expand Up @@ -2003,6 +2004,11 @@ classnames@*, classnames@^2.2.6:
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.1.tgz#dfcfa3891e306ec1dad105d0e88f4417b8535e8e"
integrity sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==

classnames@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.2.tgz#351d813bf0137fcc6a76a16b88208d2560a0d924"
integrity sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==

clean-stack@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
Expand Down

0 comments on commit f509aa0

Please sign in to comment.