Skip to content

Commit

Permalink
Merge pull request #739 from 3flex/busmessagetype
Browse files Browse the repository at this point in the history
Define a type for the type parameter on BusMessage
  • Loading branch information
nielsvanvelzen authored Dec 14, 2024
2 parents 458d6cf + 81dcfe3 commit b8862e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/components/jellyfinActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { AppStatus } from '../types/appStatus';
import { JellyfinApi } from './jellyfinApi';
import { DocumentManager } from './documentManager';
import { PlaybackManager, type PlaybackState } from './playbackManager';
import type { JellyfinMediaInformationCustomData } from '~/types/global';
import type {
BusMessageType,
JellyfinMediaInformationCustomData
} from '~/types/global';

let pingInterval: number;
let lastTranscoderPing = 0;
Expand Down Expand Up @@ -93,7 +96,7 @@ export async function reportPlaybackProgress(
state: PlaybackState,
reportingParams: PlaybackProgressInfo,
reportToServer = true,
broadcastEventName = 'playbackprogress'
broadcastEventName: BusMessageType = 'playbackprogress'
): Promise<void> {
broadcastToMessageBus({
data: getSenderReportingData(state, reportingParams),
Expand Down
4 changes: 2 additions & 2 deletions src/components/maincontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { JellyfinApi } from './jellyfinApi';
import { PlaybackManager, type PlaybackState } from './playbackManager';
import { CommandHandler } from './commandHandler';
import { getMaxBitrateSupport } from './codecSupportHelper';
import type { PlayRequest, StreamInfo } from '~/types/global';
import type { BusMessageType, PlayRequest, StreamInfo } from '~/types/global';

window.castReceiverContext = cast.framework.CastReceiverContext.getInstance();
window.playerManager = window.castReceiverContext.getPlayerManager();
Expand Down Expand Up @@ -353,7 +353,7 @@ export function processMessage(data: any): void {
* @returns Promise
*/
export function reportEvent(
name: string,
name: BusMessageType,
reportToServer: boolean
): Promise<void> {
const playbackState = PlaybackManager.playbackState;
Expand Down
13 changes: 12 additions & 1 deletion src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ import type {
Track
} from 'chromecast-caf-receiver/cast.framework.messages';

type BusMessageType =
| 'connectionerror'
| 'error'
| 'playbackerror'
| 'playbackprogress'
| 'playbackstart'
| 'playbackstop'
| 'playstatechange'
| 'repeatmodechange'
| 'volumechange';

// Messagebus message
export interface BusMessage {
type: string;
type: BusMessageType;
message?: string;
data?: string;
}
Expand Down

0 comments on commit b8862e1

Please sign in to comment.