@chat21/chat21-ionic 3.0.6-2.4 → 3.0.6-2.4-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -3
- package/deploy_prod.sh +3 -3
- package/package.json +2 -1
- package/src/app/app.component.ts +85 -88
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +2 -2
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +1 -0
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +1 -2
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +5 -3
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +3 -3
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +10 -55
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +8 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +2 -0
- package/src/app/components/image-viewer/image-viewer.component.ts +28 -10
- package/src/app/pages/conversation-detail/conversation-detail.page.html +36 -17
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +127 -227
- package/src/app/pages/conversations-list/conversations-list.page.html +18 -10
- package/src/app/pages/conversations-list/conversations-list.page.ts +58 -181
- package/src/chat-config-pre-test.json +2 -1
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +18 -3
- package/src/chat21-core/utils/utils-message.ts +96 -96
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
MESSAGE_TYPE_INFO,
|
|
3
|
+
MESSAGE_TYPE_MINE,
|
|
4
|
+
MESSAGE_TYPE_OTHERS,
|
|
5
|
+
MESSAGE_TYPE_DATE,
|
|
6
|
+
MAX_WIDTH_IMAGES,
|
|
7
|
+
CHANNEL_TYPE_GROUP,
|
|
8
|
+
TYPE_SUPPORT_GROUP
|
|
9
9
|
} from '../../chat21-core/utils/constants';
|
|
10
10
|
|
|
11
11
|
/** */
|
|
12
12
|
export function isFirstMessage(i: number) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.error('error: ', err);
|
|
13
|
+
if (i > 0) {
|
|
14
|
+
try {
|
|
15
|
+
const message = this.messages[i];
|
|
16
|
+
const prevMessage = this.messages[i - 1];
|
|
17
|
+
if (prevMessage.sender !== message.sender || message.headerDate || (prevMessage && this.isInfo(prevMessage))) {
|
|
18
|
+
return true;
|
|
23
19
|
}
|
|
20
|
+
return false;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error('error: ', err);
|
|
24
23
|
}
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/** */
|
|
28
28
|
export function isImage(message: any) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (message && message.type && message.metadata && message.metadata.src && message.type === 'image') {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function isFrame(message: any) {
|
|
@@ -41,110 +41,110 @@ export function isFrame(message: any) {
|
|
|
41
41
|
|
|
42
42
|
/** */
|
|
43
43
|
export function isFile(message: any) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
if (message && message.type && message.metadata && message.metadata.src && message.type === 'file') {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** */
|
|
51
51
|
export function isInfo(message: any) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (message.attributes && (message.attributes.subtype === 'info' || message.attributes.subtype === 'info/support')) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/** */
|
|
59
59
|
export function isMine(message: any) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
if (message.isSender) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/** */
|
|
67
67
|
export function messageType(msgType: string, message: any) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
if (msgType === MESSAGE_TYPE_INFO) {
|
|
75
|
-
return this.isInfo(message);
|
|
76
|
-
}
|
|
77
|
-
if (msgType === MESSAGE_TYPE_MINE) {
|
|
78
|
-
return this.isMine(message);
|
|
68
|
+
if (msgType === MESSAGE_TYPE_DATE) {
|
|
69
|
+
if (message.headerDate && message.headerDate !== '') {
|
|
70
|
+
return true;
|
|
79
71
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (msgType === MESSAGE_TYPE_INFO) {
|
|
75
|
+
return this.isInfo(message);
|
|
76
|
+
}
|
|
77
|
+
if (msgType === MESSAGE_TYPE_MINE) {
|
|
78
|
+
return this.isMine(message);
|
|
79
|
+
}
|
|
80
|
+
if (msgType === MESSAGE_TYPE_OTHERS) {
|
|
81
|
+
if (this.isInfo(message) === false && this.isMine(message) === false) {
|
|
82
|
+
return true;
|
|
85
83
|
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function isEmojii_2(message: any){
|
|
89
|
-
// https://localcoder.org/javascript-detect-if-a-string-contains-only-unicode-emojis
|
|
90
|
-
const onlyEmojis = message.replace(new RegExp('[\u0000-\u1eeff]', 'g'), '')
|
|
91
|
-
const visibleChars = message.replace(new RegExp('[\n\r\s]+|( )+', 'g'), '')
|
|
92
|
-
return onlyEmojis.length === visibleChars.length
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
88
|
export function isEmojii(message: any){
|
|
98
|
-
|
|
99
|
-
let emoji = '';
|
|
89
|
+
|
|
90
|
+
// let emoji = '';
|
|
91
|
+
// try {
|
|
92
|
+
// emoji = message.trim(); // .charAt(0);
|
|
93
|
+
// if (emoji.length > 2) {
|
|
94
|
+
// return false;
|
|
95
|
+
// }
|
|
96
|
+
// } catch (e) {
|
|
97
|
+
// return false;
|
|
98
|
+
// }
|
|
99
|
+
// // const regex = '(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])'
|
|
100
|
+
// const ranges = ['(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])'];
|
|
101
|
+
// if (emoji.match(ranges.join('|'))) {
|
|
102
|
+
// return true;
|
|
103
|
+
// } else {
|
|
104
|
+
// return false;
|
|
105
|
+
// }
|
|
106
|
+
// https://localcoder.org/javascript-detect-if-a-string-contains-only-unicode-emojis
|
|
100
107
|
try {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const ranges =['(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c\ude32-\ude3a]|[\ud83c\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])'];
|
|
109
|
-
|
|
110
|
-
if (emoji.match(ranges.join('|'))) {
|
|
111
|
-
return true;
|
|
112
|
-
} else {
|
|
113
|
-
return false;
|
|
108
|
+
if(!message) return false;
|
|
109
|
+
const onlyEmojis = message.replace(new RegExp('[\u0000-\u1eeff]', 'g'), '')
|
|
110
|
+
const visibleChars = message.replace(new RegExp('[\n\r\s]+|( )+', 'g'), '')
|
|
111
|
+
if(onlyEmojis === '' || visibleChars == '') return false
|
|
112
|
+
return onlyEmojis.length === visibleChars.length
|
|
113
|
+
} catch(e) {
|
|
114
|
+
return false
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
|
|
118
|
-
|
|
119
119
|
/** */
|
|
120
120
|
export function getSizeImg(message: any, maxWidthImage?: number): any {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
return sizeImage;
|
|
136
|
-
} catch (err) {
|
|
137
|
-
console.error('error: ', err);
|
|
138
|
-
return;
|
|
121
|
+
try {
|
|
122
|
+
const metadata = message.metadata;
|
|
123
|
+
const sizeImage = {
|
|
124
|
+
width: metadata.width,
|
|
125
|
+
height: metadata.height
|
|
126
|
+
};
|
|
127
|
+
if (!maxWidthImage) {
|
|
128
|
+
maxWidthImage = MAX_WIDTH_IMAGES;
|
|
129
|
+
}
|
|
130
|
+
if (metadata.width && metadata.width > maxWidthImage) {
|
|
131
|
+
const rapporto = (metadata['width'] / metadata['height']);
|
|
132
|
+
sizeImage.width = maxWidthImage;
|
|
133
|
+
sizeImage.height = maxWidthImage / rapporto;
|
|
139
134
|
}
|
|
135
|
+
return sizeImage;
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.error('error: ', err);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** */
|
|
143
143
|
export function isChannelTypeGroup(channelType: string) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
if (channelType === CHANNEL_TYPE_GROUP || channelType === TYPE_SUPPORT_GROUP) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
|