merge devel
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1648,6 +1648,13 @@
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
|
||||
@@ -1648,6 +1648,13 @@
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "Failed to initialize audio recording",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "Pin",
|
||||
"defaultMessage": "Pin",
|
||||
|
||||
@@ -1661,5 +1661,12 @@
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +291,10 @@
|
||||
"defaultMessage": "Invalid ID",
|
||||
"description": "Error message"
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available"
|
||||
},
|
||||
"file_attachment_too_large": {
|
||||
"defaultMessage": "The file size {size} exceeds the {limit} limit.",
|
||||
"description": "Error message when attachment is too large"
|
||||
|
||||
@@ -1661,5 +1661,12 @@
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,5 +1661,12 @@
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,5 +1661,12 @@
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,5 +1661,12 @@
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,5 +1661,12 @@
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,5 +1661,12 @@
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"failed_to_init_audio": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Failed to initialize audio recording",
|
||||
"description": "Error message when audio is not available",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ class TinodeWeb extends React.Component {
|
||||
}).then(token => {
|
||||
if (token) {
|
||||
return token;
|
||||
} else {
|
||||
} else if (typeof Notification != 'undefined') {
|
||||
// Try to request permissions.
|
||||
return Notification.requestPermission().then(permission => {
|
||||
if (permission === 'granted') {
|
||||
@@ -450,6 +450,7 @@ class TinodeWeb extends React.Component {
|
||||
}
|
||||
});
|
||||
}
|
||||
throw new Error("Notifications are not supported");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class AudioPlayer extends React.PureComponent {
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.audioPlayer) {
|
||||
this.audioPlayer.oncanplay = null;
|
||||
this.audioPlayer.onloadedmetadata = null;
|
||||
this.audioPlayer.ontimeupdate = null;
|
||||
this.audioPlayer.onended = null;
|
||||
this.audioPlayer.pause();
|
||||
@@ -94,7 +94,7 @@ class AudioPlayer extends React.PureComponent {
|
||||
|
||||
initAudio() {
|
||||
this.audioPlayer = new Audio(this.props.src);
|
||||
this.audioPlayer.oncanplay = _ => this.setState({canPlay: true});
|
||||
this.audioPlayer.onloadedmetadata = _ => this.setState({canPlay: true});
|
||||
this.audioPlayer.ontimeupdate = _ => this.setState({
|
||||
currentTime: secondsToTime(this.audioPlayer.currentTime, this.state.longMin)
|
||||
});
|
||||
@@ -149,7 +149,7 @@ class AudioPlayer extends React.PureComponent {
|
||||
this.canvasContext.strokeStyle = BAR_COLOR_DARK;
|
||||
for (let i = 0; i < this.viewBuffer.length; i++) {
|
||||
let x = 1 + i * (LINE_WIDTH + SPACING) + LINE_WIDTH * 0.5;
|
||||
let y = this.viewBuffer[i] * height * 0.9;
|
||||
let y = Math.max(this.viewBuffer[i] * height * 0.9, 1);
|
||||
|
||||
const color = x < thumbAt ? BAR_COLOR_DARK : BAR_COLOR;
|
||||
if (this.canvasContext.strokeStyle != color) {
|
||||
@@ -159,7 +159,7 @@ class AudioPlayer extends React.PureComponent {
|
||||
}
|
||||
|
||||
this.canvasContext.moveTo(x, (height - y) * 0.5);
|
||||
this.canvasContext.lineTo(x, height * 0.5 + y * 0.5);
|
||||
this.canvasContext.lineTo(x, (height + y) * 0.5);
|
||||
}
|
||||
// Actually draw the bars on canvas.
|
||||
this.canvasContext.stroke();
|
||||
@@ -216,10 +216,11 @@ class AudioPlayer extends React.PureComponent {
|
||||
if (!this.state.canPlay) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.state.playing) {
|
||||
this.audioPlayer.pause();
|
||||
this.setState({playing: false});
|
||||
} else {
|
||||
} else if (this.audioPlayer.readyState >= 2) {
|
||||
this.audioPlayer.play();
|
||||
this.setState({playing: true}, this.visualize);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,11 @@ const VISUALIZATION_BARS = 96;
|
||||
// Maximum number of samples per bar.
|
||||
const MAX_SAMPLES_PER_BAR = 10;
|
||||
|
||||
// Recording format.
|
||||
const AUDIO_MIME_TYPE = 'audio/webm';
|
||||
// Default recording format (FF, Chrome except on iOS).
|
||||
const DEFAULT_AUDIO_MIME_TYPE = 'audio/webm';
|
||||
// Safari supports only mp4 as audio recording format.
|
||||
const SAFARI_AUDIO_MIME_TYPE = 'audio/mp4';
|
||||
const AUDIO_MIME_TYPES = [DEFAULT_AUDIO_MIME_TYPE, SAFARI_AUDIO_MIME_TYPE, ''];
|
||||
|
||||
const messages = defineMessages({
|
||||
icon_title_delete: {
|
||||
@@ -55,6 +58,11 @@ const messages = defineMessages({
|
||||
defaultMessage: 'Send message',
|
||||
description: 'Icon tool tip for sending a message'
|
||||
},
|
||||
failed_to_init_audio: {
|
||||
id: 'failed_to_init_audio',
|
||||
defaultMessage: 'Failed to initialize audio recording',
|
||||
description: 'Error message when audio is not available'
|
||||
}
|
||||
});
|
||||
|
||||
class AudioRecorder extends React.PureComponent {
|
||||
@@ -188,10 +196,10 @@ class AudioRecorder extends React.PureComponent {
|
||||
this.canvasContext.beginPath();
|
||||
for (let i = 0; i < this.viewBuffer.length; i++) {
|
||||
let x = i * (LINE_WIDTH + SPACING) - dx;
|
||||
let y = Math.min(this.viewBuffer[i] / BAR_SCALE, 0.9) * height;
|
||||
let y = Math.max(Math.min(this.viewBuffer[i] / BAR_SCALE, 0.9) * height, 1);
|
||||
|
||||
this.canvasContext.moveTo(x, (height - y) * 0.5);
|
||||
this.canvasContext.lineTo(x, height * 0.5 + y * 0.5);
|
||||
this.canvasContext.lineTo(x, (height + y) * 0.5);
|
||||
}
|
||||
// Actually draw the bars on canvas.
|
||||
this.canvasContext.stroke();
|
||||
@@ -261,11 +269,29 @@ class AudioRecorder extends React.PureComponent {
|
||||
|
||||
initMediaRecording(stream) {
|
||||
this.stream = stream;
|
||||
this.mediaRecorder = new MediaRecorder(stream, {mimeType: AUDIO_MIME_TYPE, audioBitsPerSecond: 24_000});
|
||||
AUDIO_MIME_TYPES.some(mimeType => {
|
||||
if (MediaRecorder.isTypeSupported(mimeType)) {
|
||||
this.mediaRecorder = new MediaRecorder(stream, {mimeType: mimeType, audioBitsPerSecond: 24_000});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!this.mediaRecorder) {
|
||||
console.warn('MediaRecorder failed to initialize: no supported audio formats');
|
||||
this.props.onError(this.props.intl.formatMessage(messages.failed_to_init_audio));
|
||||
return;
|
||||
}
|
||||
|
||||
// The following code is needed for visualization.
|
||||
this.audioContext = new AudioContext();
|
||||
this.audioInput = this.audioContext.createMediaStreamSource(stream);
|
||||
if (!this.audioInput) {
|
||||
console.warn('createMediaStreamSource returned null: audio input unavailable');
|
||||
this.props.onError(this.props.intl.formatMessage(messages.failed_to_init_audio));
|
||||
return;
|
||||
}
|
||||
|
||||
this.analyser = this.audioContext.createAnalyser();
|
||||
this.analyser.fftSize = BUFFER_SIZE;
|
||||
this.audioInput.connect(this.analyser);
|
||||
@@ -305,11 +331,14 @@ class AudioRecorder extends React.PureComponent {
|
||||
}
|
||||
|
||||
// Obtain data in a form sutable for sending or playing back.
|
||||
// If duration is valid, apply fix for Chrome's WebM duration bug.
|
||||
getRecording(mimeType) {
|
||||
mimeType = mimeType || AUDIO_MIME_TYPE;
|
||||
mimeType = mimeType || DEFAULT_AUDIO_MIME_TYPE;
|
||||
let blob = new Blob(this.audioChunks, {type: mimeType});
|
||||
return fixWebmDuration(blob, mimeType)
|
||||
// If duration is valid, apply fix for Chrome's WebM duration bug.
|
||||
const result = mimeType == DEFAULT_AUDIO_MIME_TYPE ?
|
||||
fixWebmDuration(blob, mimeType) :
|
||||
Promise.resolve(blob);
|
||||
return result
|
||||
.then(fixedBlob => { blob = fixedBlob; return fixedBlob.arrayBuffer(); })
|
||||
.then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff))
|
||||
.then(decoded => this.createPreview(decoded))
|
||||
@@ -347,7 +376,9 @@ class AudioRecorder extends React.PureComponent {
|
||||
}
|
||||
|
||||
cleanUp() {
|
||||
if (this.audioInput) {
|
||||
this.audioInput.disconnect();
|
||||
}
|
||||
this.stream.getTracks().forEach(track => track.stop());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+7
-6
@@ -7657,7 +7657,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
}).then(token => {
|
||||
if (token) {
|
||||
return token;
|
||||
} else {
|
||||
} else if (typeof Notification != 'undefined') {
|
||||
return Notification.requestPermission().then(permission => {
|
||||
if (permission === 'granted') {
|
||||
return (0,firebase_messaging__WEBPACK_IMPORTED_MODULE_3__.getToken)(fcm, {
|
||||
@@ -7675,6 +7675,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
}
|
||||
});
|
||||
}
|
||||
throw new Error("Notifications are not supported");
|
||||
});
|
||||
}
|
||||
handleResize() {
|
||||
@@ -9637,7 +9638,7 @@ class AudioPlayer extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
|
||||
}
|
||||
componentWillUnmount() {
|
||||
if (this.audioPlayer) {
|
||||
this.audioPlayer.oncanplay = null;
|
||||
this.audioPlayer.onloadedmetadata = null;
|
||||
this.audioPlayer.ontimeupdate = null;
|
||||
this.audioPlayer.onended = null;
|
||||
this.audioPlayer.pause();
|
||||
@@ -9660,7 +9661,7 @@ class AudioPlayer extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
|
||||
}
|
||||
initAudio() {
|
||||
this.audioPlayer = new Audio(this.props.src);
|
||||
this.audioPlayer.oncanplay = _ => this.setState({
|
||||
this.audioPlayer.onloadedmetadata = _ => this.setState({
|
||||
canPlay: true
|
||||
});
|
||||
this.audioPlayer.ontimeupdate = _ => this.setState({
|
||||
@@ -9703,7 +9704,7 @@ class AudioPlayer extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
|
||||
this.canvasContext.strokeStyle = BAR_COLOR_DARK;
|
||||
for (let i = 0; i < this.viewBuffer.length; i++) {
|
||||
let x = 1 + i * (LINE_WIDTH + SPACING) + LINE_WIDTH * 0.5;
|
||||
let y = this.viewBuffer[i] * height * 0.9;
|
||||
let y = Math.max(this.viewBuffer[i] * height * 0.9, 1);
|
||||
const color = x < thumbAt ? BAR_COLOR_DARK : BAR_COLOR;
|
||||
if (this.canvasContext.strokeStyle != color) {
|
||||
this.canvasContext.stroke();
|
||||
@@ -9711,7 +9712,7 @@ class AudioPlayer extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
|
||||
this.canvasContext.strokeStyle = color;
|
||||
}
|
||||
this.canvasContext.moveTo(x, (height - y) * 0.5);
|
||||
this.canvasContext.lineTo(x, height * 0.5 + y * 0.5);
|
||||
this.canvasContext.lineTo(x, (height + y) * 0.5);
|
||||
}
|
||||
this.canvasContext.stroke();
|
||||
if (this.props.duration) {
|
||||
@@ -9762,7 +9763,7 @@ class AudioPlayer extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
|
||||
this.setState({
|
||||
playing: false
|
||||
});
|
||||
} else {
|
||||
} else if (this.audioPlayer.readyState >= 2) {
|
||||
this.audioPlayer.play();
|
||||
this.setState({
|
||||
playing: true
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -37,7 +37,9 @@ const BAR_COLOR = '#BBBD';
|
||||
const BAR_SCALE = 64.0;
|
||||
const VISUALIZATION_BARS = 96;
|
||||
const MAX_SAMPLES_PER_BAR = 10;
|
||||
const AUDIO_MIME_TYPE = 'audio/webm';
|
||||
const DEFAULT_AUDIO_MIME_TYPE = 'audio/webm';
|
||||
const SAFARI_AUDIO_MIME_TYPE = 'audio/mp4';
|
||||
const AUDIO_MIME_TYPES = [DEFAULT_AUDIO_MIME_TYPE, SAFARI_AUDIO_MIME_TYPE, ''];
|
||||
const messages = (0,react_intl__WEBPACK_IMPORTED_MODULE_1__.defineMessages)({
|
||||
icon_title_delete: {
|
||||
id: "icon_title_delete",
|
||||
@@ -66,6 +68,13 @@ const messages = (0,react_intl__WEBPACK_IMPORTED_MODULE_1__.defineMessages)({
|
||||
"type": 0,
|
||||
"value": "Send message"
|
||||
}]
|
||||
},
|
||||
failed_to_init_audio: {
|
||||
id: "failed_to_init_audio",
|
||||
defaultMessage: [{
|
||||
"type": 0,
|
||||
"value": "Failed to initialize audio recording"
|
||||
}]
|
||||
}
|
||||
});
|
||||
class AudioRecorder extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComponent) {
|
||||
@@ -170,9 +179,9 @@ class AudioRecorder extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCo
|
||||
this.canvasContext.beginPath();
|
||||
for (let i = 0; i < this.viewBuffer.length; i++) {
|
||||
let x = i * (LINE_WIDTH + SPACING) - dx;
|
||||
let y = Math.min(this.viewBuffer[i] / BAR_SCALE, 0.9) * height;
|
||||
let y = Math.max(Math.min(this.viewBuffer[i] / BAR_SCALE, 0.9) * height, 1);
|
||||
this.canvasContext.moveTo(x, (height - y) * 0.5);
|
||||
this.canvasContext.lineTo(x, height * 0.5 + y * 0.5);
|
||||
this.canvasContext.lineTo(x, (height + y) * 0.5);
|
||||
}
|
||||
this.canvasContext.stroke();
|
||||
const now = new Date().getTime();
|
||||
@@ -237,12 +246,28 @@ class AudioRecorder extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCo
|
||||
}
|
||||
initMediaRecording(stream) {
|
||||
this.stream = stream;
|
||||
AUDIO_MIME_TYPES.some(mimeType => {
|
||||
if (MediaRecorder.isTypeSupported(mimeType)) {
|
||||
this.mediaRecorder = new MediaRecorder(stream, {
|
||||
mimeType: AUDIO_MIME_TYPE,
|
||||
mimeType: mimeType,
|
||||
audioBitsPerSecond: 24_000
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!this.mediaRecorder) {
|
||||
console.warn('MediaRecorder failed to initialize: no supported audio formats');
|
||||
this.props.onError(this.props.intl.formatMessage(messages.failed_to_init_audio));
|
||||
return;
|
||||
}
|
||||
this.audioContext = new AudioContext();
|
||||
this.audioInput = this.audioContext.createMediaStreamSource(stream);
|
||||
if (!this.audioInput) {
|
||||
console.warn('createMediaStreamSource returned null: audio input unavailable');
|
||||
this.props.onError(this.props.intl.formatMessage(messages.failed_to_init_audio));
|
||||
return;
|
||||
}
|
||||
this.analyser = this.audioContext.createAnalyser();
|
||||
this.analyser.fftSize = BUFFER_SIZE;
|
||||
this.audioInput.connect(this.analyser);
|
||||
@@ -275,11 +300,12 @@ class AudioRecorder extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCo
|
||||
this.recordingTimestamp = this.startedOn;
|
||||
}
|
||||
getRecording(mimeType) {
|
||||
mimeType = mimeType || AUDIO_MIME_TYPE;
|
||||
mimeType = mimeType || DEFAULT_AUDIO_MIME_TYPE;
|
||||
let blob = new Blob(this.audioChunks, {
|
||||
type: mimeType
|
||||
});
|
||||
return webm_duration_fix__WEBPACK_IMPORTED_MODULE_3___default()(blob, mimeType).then(fixedBlob => {
|
||||
const result = mimeType == DEFAULT_AUDIO_MIME_TYPE ? webm_duration_fix__WEBPACK_IMPORTED_MODULE_3___default()(blob, mimeType) : Promise.resolve(blob);
|
||||
return result.then(fixedBlob => {
|
||||
blob = fixedBlob;
|
||||
return fixedBlob.arrayBuffer();
|
||||
}).then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff)).then(decoded => this.createPreview(decoded)).then(preview => ({
|
||||
@@ -311,7 +337,9 @@ class AudioRecorder extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCo
|
||||
return buffer;
|
||||
}
|
||||
cleanUp() {
|
||||
if (this.audioInput) {
|
||||
this.audioInput.disconnect();
|
||||
}
|
||||
this.stream.getTracks().forEach(track => track.stop());
|
||||
}
|
||||
render() {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+14
-72
@@ -410,7 +410,6 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ "EXPIRE_PROMISES_TIMEOUT": () => (/* binding */ EXPIRE_PROMISES_TIMEOUT),
|
||||
/* harmony export */ "LIBRARY": () => (/* binding */ LIBRARY),
|
||||
/* harmony export */ "LOCAL_SEQID": () => (/* binding */ LOCAL_SEQID),
|
||||
/* harmony export */ "MAX_PINNED_COUNT": () => (/* binding */ MAX_PINNED_COUNT),
|
||||
/* harmony export */ "MESSAGE_STATUS_FAILED": () => (/* binding */ MESSAGE_STATUS_FAILED),
|
||||
/* harmony export */ "MESSAGE_STATUS_FATAL": () => (/* binding */ MESSAGE_STATUS_FATAL),
|
||||
/* harmony export */ "MESSAGE_STATUS_NONE": () => (/* binding */ MESSAGE_STATUS_NONE),
|
||||
@@ -464,7 +463,6 @@ const EXPIRE_PROMISES_PERIOD = 1000;
|
||||
const RECV_TIMEOUT = 100;
|
||||
const DEFAULT_MESSAGES_PAGE = 24;
|
||||
const DEL_CHAR = '\u2421';
|
||||
const MAX_PINNED_COUNT = 5;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -1308,7 +1306,7 @@ function _serializeMessage(dst, msg) {
|
||||
}
|
||||
var _topic_fields = {
|
||||
writable: true,
|
||||
value: ['created', 'updated', 'deleted', 'touched', 'read', 'recv', 'seq', 'clear', 'defacs', 'creds', 'public', 'trusted', 'private', '_aux', '_deleted']
|
||||
value: ['created', 'updated', 'deleted', 'read', 'recv', 'seq', 'clear', 'defacs', 'creds', 'public', 'trusted', 'private', 'touched', '_deleted']
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
@@ -3030,6 +3028,11 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
let XHRProvider;
|
||||
function addURLParam(relUrl, key, value) {
|
||||
const url = new URL(relUrl, window.location.origin);
|
||||
url.searchParams.append(key, value);
|
||||
return url.toString().substring(window.location.origin.length);
|
||||
}
|
||||
class LargeFileHelper {
|
||||
constructor(tinode, version) {
|
||||
this._tinode = tinode;
|
||||
@@ -3160,6 +3163,7 @@ class LargeFileHelper {
|
||||
const instance = this;
|
||||
const xhr = new XHRProvider();
|
||||
this.xhr.push(xhr);
|
||||
relativeUrl = addURLParam(relativeUrl, 'asatt', '1');
|
||||
xhr.open('GET', relativeUrl, true);
|
||||
xhr.setRequestHeader('X-Tinode-APIKey', this._apiKey);
|
||||
xhr.setRequestHeader('X-Tinode-Auth', 'Token ' + this._authToken.token);
|
||||
@@ -3323,10 +3327,6 @@ class MetaGetBuilder {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
withAux() {
|
||||
this.what['aux'] = true;
|
||||
return this;
|
||||
}
|
||||
withDel(since, limit) {
|
||||
if (since || limit) {
|
||||
this.what['del'] = {
|
||||
@@ -3345,7 +3345,7 @@ class MetaGetBuilder {
|
||||
build() {
|
||||
const what = [];
|
||||
let params = {};
|
||||
['data', 'sub', 'desc', 'tags', 'cred', 'aux', 'del'].forEach(key => {
|
||||
['data', 'sub', 'desc', 'tags', 'cred', 'del'].forEach(key => {
|
||||
if (this.what.hasOwnProperty(key)) {
|
||||
what.push(key);
|
||||
if (Object.getOwnPropertyNames(this.what[key]).length > 0) {
|
||||
@@ -3425,7 +3425,6 @@ class Topic {
|
||||
this._recvNotificationTimer = null;
|
||||
this._tags = [];
|
||||
this._credentials = [];
|
||||
this._aux = {};
|
||||
this._messageVersions = {};
|
||||
this._messages = new _cbuffer_js__WEBPACK_IMPORTED_MODULE_1__["default"]((a, b) => {
|
||||
return a.seq - b.seq;
|
||||
@@ -3445,7 +3444,6 @@ class Topic {
|
||||
this.onSubsUpdated = callbacks.onSubsUpdated;
|
||||
this.onTagsUpdated = callbacks.onTagsUpdated;
|
||||
this.onCredsUpdated = callbacks.onCredsUpdated;
|
||||
this.onAuxUpdated = callbacks.onAuxUpdated;
|
||||
this.onDeleteTopic = callbacks.onDeleteTopic;
|
||||
this.onAllMessagesReceived = callbacks.onAllMessagesReceived;
|
||||
}
|
||||
@@ -3690,9 +3688,6 @@ class Topic {
|
||||
if (params.cred) {
|
||||
this._processMetaCreds([params.cred], true);
|
||||
}
|
||||
if (params.aux) {
|
||||
this._processMetaAux(params.aux);
|
||||
}
|
||||
return ctrl;
|
||||
});
|
||||
}
|
||||
@@ -3726,38 +3721,6 @@ class Topic {
|
||||
}
|
||||
});
|
||||
}
|
||||
pinMessage(seq, pin) {
|
||||
let pinned = this.aux('pins');
|
||||
if (!Array.isArray(pinned)) {
|
||||
pinned = [];
|
||||
}
|
||||
let changed = false;
|
||||
if (pin) {
|
||||
if (!pinned.includes(seq)) {
|
||||
changed = true;
|
||||
if (pinned.length == _config_js__WEBPACK_IMPORTED_MODULE_3__.MAX_PINNED_COUNT) {
|
||||
pinned.shift();
|
||||
}
|
||||
pinned.push(seq);
|
||||
}
|
||||
} else {
|
||||
if (pinned.includes(seq)) {
|
||||
changed = true;
|
||||
pinned = pinned.filter(id => id != seq);
|
||||
if (pinned.length == 0) {
|
||||
pinned = _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
return this.setMeta({
|
||||
aux: {
|
||||
pins: pinned
|
||||
}
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
delMessages(ranges, hard) {
|
||||
if (!this._attached) {
|
||||
return Promise.reject(new Error("Cannot delete messages in inactive topic"));
|
||||
@@ -3987,9 +3950,6 @@ class Topic {
|
||||
tags() {
|
||||
return this._tags.slice(0);
|
||||
}
|
||||
aux(key) {
|
||||
return this._aux[key];
|
||||
}
|
||||
subscriber(uid) {
|
||||
return this._users[uid];
|
||||
}
|
||||
@@ -4290,9 +4250,6 @@ class Topic {
|
||||
if (meta.cred) {
|
||||
this._processMetaCreds(meta.cred);
|
||||
}
|
||||
if (meta.aux) {
|
||||
this._processMetaAux(meta.aux);
|
||||
}
|
||||
if (this.onMeta) {
|
||||
this.onMeta(meta);
|
||||
}
|
||||
@@ -4320,9 +4277,6 @@ class Topic {
|
||||
this.getMeta(this.startMetaQuery().withLaterOneSub(pres.src).build());
|
||||
}
|
||||
break;
|
||||
case 'aux':
|
||||
this.getMeta(this.startMetaQuery().withAux().build());
|
||||
break;
|
||||
case 'acs':
|
||||
uid = pres.src || this._tinode.getCurrentUserID();
|
||||
user = this._users[uid];
|
||||
@@ -4437,31 +4391,22 @@ class Topic {
|
||||
}
|
||||
}
|
||||
_processMetaTags(tags) {
|
||||
if (tags == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR || tags.length == 1 && tags[0] == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR) {
|
||||
if (tags.length == 1 && tags[0] == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR) {
|
||||
tags = [];
|
||||
}
|
||||
this._tags = tags;
|
||||
this._tinode._db.updTopic(this);
|
||||
if (this.onTagsUpdated) {
|
||||
this.onTagsUpdated(tags);
|
||||
}
|
||||
}
|
||||
_processMetaCreds(creds) {}
|
||||
_processMetaAux(aux) {
|
||||
aux = !aux || aux == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR ? {} : aux;
|
||||
this._aux = (0,_utils_js__WEBPACK_IMPORTED_MODULE_6__.mergeObj)(this._aux, aux);
|
||||
this._tinode._db.updTopic(this);
|
||||
if (this.onAuxUpdated) {
|
||||
this.onAuxUpdated(this._aux);
|
||||
}
|
||||
}
|
||||
_processDelMessages(clear, delseq) {
|
||||
this._maxDel = Math.max(clear, this._maxDel);
|
||||
this.clear = Math.max(clear, this.clear);
|
||||
const topic = this;
|
||||
let count = 0;
|
||||
if (Array.isArray(delseq)) {
|
||||
delseq.forEach(range => {
|
||||
delseq.forEach(function (range) {
|
||||
if (!range.hi) {
|
||||
count++;
|
||||
topic.flushMessage(range.low);
|
||||
@@ -4983,7 +4928,7 @@ function normalizeArray(arr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
out.sort().filter((item, pos, ary) => {
|
||||
out.sort().filter(function (item, pos, ary) {
|
||||
return !pos || item != ary[pos - 1];
|
||||
});
|
||||
}
|
||||
@@ -5005,7 +4950,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "PACKAGE_VERSION": () => (/* binding */ PACKAGE_VERSION)
|
||||
/* harmony export */ });
|
||||
const PACKAGE_VERSION = "0.23.0-rc1";
|
||||
const PACKAGE_VERSION = "0.22.3";
|
||||
|
||||
/***/ })
|
||||
|
||||
@@ -5725,9 +5670,6 @@ class Tinode {
|
||||
if (setParams.tags) {
|
||||
pkt.sub.set.tags = setParams.tags;
|
||||
}
|
||||
if (setParams.aux) {
|
||||
pkt.sub.set.aux = setParams.aux;
|
||||
}
|
||||
}
|
||||
return _classPrivateMethodGet(this, _send, _send2).call(this, pkt, pkt.sub.id);
|
||||
}
|
||||
@@ -5842,7 +5784,7 @@ class Tinode {
|
||||
const pkt = _classPrivateMethodGet(this, _initPacket, _initPacket2).call(this, 'set', topic);
|
||||
const what = [];
|
||||
if (params) {
|
||||
['desc', 'sub', 'tags', 'cred', 'aux'].forEach(key => {
|
||||
['desc', 'sub', 'tags', 'cred', 'ephemeral'].forEach(function (key) {
|
||||
if (params.hasOwnProperty(key)) {
|
||||
what.push(key);
|
||||
pkt.set[key] = params[key];
|
||||
@@ -6268,7 +6210,7 @@ function _initPacket2(type, topic) {
|
||||
'desc': {},
|
||||
'sub': {},
|
||||
'tags': [],
|
||||
'aux': {}
|
||||
'ephemeral': {}
|
||||
}
|
||||
};
|
||||
case 'del':
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user