Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls integration #86

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}