Skip to content

Commit

Permalink
Fix slash command behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 committed Apr 11, 2020
1 parent cc9eb51 commit 87c0305
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Mattermost plugin to enable voice messaging.",
"homepage_url": "https://github.com/streamer45/mattermost-plugin-voice",
"support_url": "https://github.com/streamer45/mattermost-plugin-voice/issues",
"version": "0.2.0",
"version": "0.2.1",
"min_server_version": "5.12.0",
"server": {
"executables": {
Expand Down
2 changes: 1 addition & 1 deletion server/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const manifestStr = `
"description": "Mattermost plugin to enable voice messaging.",
"homepage_url": "https://github.com/streamer45/mattermost-plugin-voice",
"support_url": "https://github.com/streamer45/mattermost-plugin-voice/issues",
"version": "0.2.0",
"version": "0.2.1",
"min_server_version": "5.12.0",
"server": {
"executables": {
Expand Down
2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voice",
"version": "0.2.0",
"version": "0.2.1",
"description": "Mattermost plugin to enable voice messaging.",
"main": "src/index.js",
"scripts": {
Expand Down
5 changes: 2 additions & 3 deletions webapp/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ export const sendRecording = (channelId, rootId) => (dispatch) => {
closeRecordingModal()(dispatch);
};

export const recordVoiceMessage = () => (dispatch, getState) => {
export const recordVoiceMessage = (channelId, rootId) => (dispatch) => {
// console.log('recordVoiceMessage');
openRecordingModal()(dispatch);
const channelId = getState().entities.channels.currentChannelId;
Client.startRecording(channelId).then(() => {
Client.startRecording(channelId, rootId).then(() => {
dispatch({
type: START_RECORDING,
});
Expand Down
17 changes: 11 additions & 6 deletions webapp/src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export default class Client {
});
}

startRecording() {
startRecording(channelId, rootId) {
// console.log('client: start recording');
this.channelId = channelId || null;
this.rootId = rootId || null;
this._recording = null;
return this.recorder.start().then(() => {
this.timerID = setInterval(() => {
Expand Down Expand Up @@ -65,6 +67,7 @@ export default class Client {

_sendRecording({channelId, rootId, recording}) {
const filename = `${new Date().getTime() - recording.duration}.mp3`;

return request.
post(Client4.getFilesRoute()).
set(Client4.getOptions({method: 'post'}).headers).
Expand All @@ -89,21 +92,23 @@ export default class Client {
}

sendRecording(channelId, rootId) {
if (!channelId) {
if (!this.channelId && !channelId) {
return Promise.reject(new Error('channel id is required'));
}
const cId = this.channelId ? this.channelId : channelId;
const rId = !this.channelId && rootId ? rootId : this.rootId;
// console.log('client: send recording');
if (this._recording) {
return this._sendRecording({
channelId,
rootId,
channelId: cId,
rootId: rId,
recording: this._recording,
});
}
return this.recorder.stop().then((res) => {
return this._sendRecording({
channelId,
rootId,
channelId: cId,
rootId: rId,
recording: res,
});
});
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const manifest = JSON.parse(`
"description": "Mattermost plugin to enable voice messaging.",
"homepage_url": "https://github.com/streamer45/mattermost-plugin-voice",
"support_url": "https://github.com/streamer45/mattermost-plugin-voice/issues",
"version": "0.2.0",
"version": "0.2.1",
"min_server_version": "5.12.0",
"server": {
"executables": {
Expand Down

0 comments on commit 87c0305

Please sign in to comment.