Skip to content

Commit

Permalink
Calls integration (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
crspeller authored Nov 16, 2023
1 parent 30b1c50 commit 9beecbb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions webapp/src/calls_button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {doTranscribe} from './client';

export function callsPostButtonClickedHandler(post: any) {
doTranscribe(post.id);
}
3 changes: 3 additions & 0 deletions webapp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Config from './components/config/config';
import {doReaction, doSummarize, doTranscribe} from './client';
import {BotUsername} from './constants';
import PostEventListener from './websocket';
import {setupRedux} from './redux';

type WebappStore = Store<GlobalState, Action<Record<string, unknown>>>

Expand All @@ -25,6 +26,8 @@ export default class Plugin {

// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
public async initialize(registry: any, store: WebappStore) {
setupRedux(registry, store);

registry.registerWebSocketEventHandler(StreamingPostWebsocketEvent, this.postEventListener.handlePostUpdateWebsockets);
const LLMBotPostWithWebsockets = (props: any) => {
return (
Expand Down
29 changes: 29 additions & 0 deletions webapp/src/redux.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {combineReducers, Store, Action} from 'redux';
import {GlobalState} from '@mattermost/types/lib/store';

import {callsPostButtonClickedHandler} from './calls_button';

type WebappStore = Store<GlobalState, Action<Record<string, unknown>>>

const CallsClickHandler = 'calls_post_button_clicked_handler';

export async function setupRedux(registry: any, store: WebappStore) {
const reducer = combineReducers({
callsPostButtonClicked,
});

registry.registerReducer(reducer);
store.dispatch({
type: CallsClickHandler as any,
handler: callsPostButtonClickedHandler,
});
}

function callsPostButtonClicked(state = false, action: any) {
switch (action.type) {
case CallsClickHandler:
return action.handler || false;
default:
return state;
}
}

0 comments on commit 9beecbb

Please sign in to comment.