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

Define a type for the type parameter on BusMessage #739

Merged
merged 1 commit into from
Dec 14, 2024
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
Define a type for the type parameter on BusMessage
  • Loading branch information
3flex committed Dec 14, 2024
commit 81dcfe3ec3e8832156f16539f55b88608ce85e4f
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
Loading