Skip to content

Commit 1807243

Browse files
Support for Stickers, GIFs, Locations, and Rich Link Previews.
1 parent 1bd17a2 commit 1807243

11 files changed

+1814
-68
lines changed

live-stream/CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
3+
## v2.1.0 (27/07/2020)
4+
5+
#### Description
6+
- Support for Stickers, GIFs, Locations, and Rich Link Previews.
7+
8+
---
9+
10+
## v2.0.0 (16/06/2020)
11+
12+
#### Description
13+
- Initial release.

live-stream/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ Add the Channelize live stream div in the body tag of your website.
2424
Import the `liveStream.Channelize.js` file after body tag in your website.
2525

2626
```javascript
27-
<script src="https://cdn.channelize.io/apps/live-stream/2.0.0/liveStream.Channelize.js"></script>
27+
<script src="https://cdn.channelize.io/apps/live-stream/2.1.0/liveStream.Channelize.js"></script>
2828
```
2929

3030
##### Step 3: Import Channelize JS-SDK #####
3131

3232
Import the [`Channelize JS-SDK`](https://docs.channelize.io/javascript-sdk-introduction-overview) after body tag in your website.
3333

3434
```javascript
35-
<script src="https://cdn.channelize.io/sdk/4.2.0/browser.js"></script>
35+
<script src="https://cdn.channelize.io/sdk/4.3.0/browser.js"></script>
3636
```
3737

3838
##### Step 4: Create live stream object #####

live-stream/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
</div>
3030
</body>
3131

32-
<script src="https://cdn.channelize.io/sdk/4.2.0/browser.js"></script>
33-
<script src="https://cdn.channelize.io/apps/live-stream/2.0.0/liveStream.Channelize.js"></script>
32+
<script src="https://cdn.channelize.io/sdk/4.3.0/browser.js"></script>
33+
<script src="https://cdn.channelize.io/apps/live-stream/2.1.0/liveStream.Channelize.js"></script>
3434

3535
<script>
3636
const channelizeLiveStream = new ChannelizeLiveStream('qHvonVEyIxDLa6zh');

live-stream/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-web-live-stream",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Channelize Web Live Stream Sample App",
55
"main": "index.js",
66
"scripts": {
@@ -23,6 +23,9 @@
2323
"webpack-cli": "^3.3.10"
2424
},
2525
"dependencies": {
26+
"@giphy/js-fetch-api": "^1.6.0",
27+
"@joeattardi/emoji-button": "^3.1.1",
28+
"google-maps": "^4.3.2",
2629
"moment": "^2.26.0"
2730
}
2831
}

live-stream/src/js/adapter.js

+8
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ class ChannelizeAdapter {
319319
return cb(null, res);
320320
});
321321
}
322+
323+
getUrlMetaData(message, cb) {
324+
message.getUrlMetaData(function (err, res) {
325+
if(err) return cb(err);
326+
327+
return cb(null, res);
328+
});
329+
}
322330
}
323331

324332
export { ChannelizeAdapter as default };

live-stream/src/js/components/conversation.js

+645-17
Large diffs are not rendered by default.

live-stream/src/js/components/threads.js

+645-18
Large diffs are not rendered by default.

live-stream/src/js/constants.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const LANGUAGE_PHRASES = {
1010
GIF : "GIF",
1111
DOCUMENT : "Document",
1212
ATTACHMENT : "Attachment",
13+
SHARE_EMOJIS : "Share Emojis",
1314
SEND_ATTACHMENTS : "Send Attachments",
1415
FILE_SIZE_WARNING : "File size should be less then 25mb",
1516
LOGIN : "Login",
@@ -37,7 +38,14 @@ export const LANGUAGE_PHRASES = {
3738
TODAY : "Today",
3839
YESTERDAY : "Yesterday",
3940
MORE_OPTIONS : "More options",
40-
REACT_TO_THIS_MESSAGE : "React to this message"
41+
REACT_TO_THIS_MESSAGE : "React to this message",
42+
SEARCH : "Search",
43+
SEARCH_STICKERS : "Search Sticker",
44+
SEARCH_GIFS : "Search Gifs",
45+
CLEAR : "Clear",
46+
CUREENT_LOCATION : "Cureent Location",
47+
SHARE_LOCATION : "Share Location",
48+
SEARCH_LOCATION : "Search Location"
4149
}
4250

4351
export const IMAGES = {
@@ -51,15 +59,17 @@ export const IMAGES = {
5159
LOCATION_ICON : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/location.svg",
5260
STICKER_ICON : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/sticker.png",
5361
GIF_ICON : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/gif.png",
62+
LOADING_IMAGE : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/loading-image.gif",
5463
AVTAR : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/avtar.png",
5564
GROUP : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/group.png",
56-
MESSAGE_LOADER : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/image-loader.gif"
65+
MESSAGE_LOADER : "https://cdn.channelize.io/apps/live-stream/2.0.0/images/message-loader.gif"
5766
}
5867

5968
export const SETTINGS = {
6069
LOCATION_API_KEY : "AIzaSyBzrL8FaUvmYPIxEUd_VTPpqcACtPdniik",
6170
LOCATION_IMG_URL : "https://maps.googleapis.com/maps/api/staticmap",
6271
CONVERSATION_ID : "b30976a2-abdf-11ea-8b53-e9b8792622de",
72+
GIPHY_API_KEY : "sXpGFDGZs0Dv1mmNFvYaGUvYwKX0PWIh",
6373
ALLOW_MESSAGE_THREADING: true,
6474
REACTION_SETTINGS : {
6575
enable: true,

live-stream/src/js/liveStream.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Login from "./components/login.js";
55
import Conversation from "./components/conversation.js";
66
import Threads from "./components/threads.js";
77
import { LANGUAGE_PHRASES, SETTINGS, IMAGES } from "./constants.js";
8+
import { Loader } from 'google-maps';
89

910
class ChannelizeLiveStream {
1011
constructor(publicKey) {
@@ -22,6 +23,7 @@ class ChannelizeLiveStream {
2223
this.chAdapter = new ChannelizeAdapter(publicKey);
2324
this.conversations = {};
2425
this.threads = {};
26+
this.initGoggleMapLibraries();
2527
}
2628

2729
// Load channelize
@@ -43,6 +45,13 @@ class ChannelizeLiveStream {
4345
}
4446
}
4547

48+
initGoggleMapLibraries() {
49+
const loader = new Loader(SETTINGS.LOCATION_API_KEY, {"&libraries":"places"});
50+
loader.load().then((google) => {
51+
this.google = google;
52+
});
53+
}
54+
4655
connect(userId, accessToken, cb) {
4756
this.chAdapter.connect(userId, accessToken, (err, res) => {
4857
if (err) return cb(err);
@@ -71,9 +80,7 @@ class ChannelizeLiveStream {
7180
this.renderLogin();
7281
}
7382
}
74-
7583

76-
7784
loadConversation(conversationId) {
7885
// Destory the login screen
7986
this.destroyLogin();

live-stream/src/js/utility.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import moment from 'moment';
2-
import { LANGUAGE_PHRASES } from "./constants.js";
2+
import { LANGUAGE_PHRASES, SETTINGS } from "./constants.js";
3+
import { GiphyFetch } from '@giphy/js-fetch-api'
34

45
class Utility {
56
constructor() {}
@@ -101,6 +102,27 @@ class Utility {
101102
updatedDuration = ((Math.floor(actualDuration / 60) + (actualDuration % 60) / 100).toFixed(2)).toString().replace('.',':');
102103
return updatedDuration;
103104
}
105+
106+
async getStickersGifs(contentType = 'stickers', offset = 0, limit = 15, searchTerm = null, language = 'en') {
107+
const giphy = new GiphyFetch(SETTINGS.GIPHY_API_KEY);
108+
try {
109+
if (searchTerm) {
110+
const { data: gifs } = await giphy.search(searchTerm, { type: contentType, offset, limit, lang: language })
111+
return gifs;
112+
}
113+
const { data: gifs } = await giphy.trending({ type: contentType, offset, limit, lang: language })
114+
return gifs;
115+
} catch (error) {
116+
return [];
117+
}
118+
}
119+
120+
getUrls(text) {
121+
if (text) {
122+
return text.match(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9])/igm) || [];
123+
}
124+
return [];
125+
}
104126
}
105127

106128
export { Utility as default };

0 commit comments

Comments
 (0)