aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/messageTypes.ts
blob: 1c69388a8ddadd2693d9588b0a6b1af6b8787b6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Message and Response Types
//

import { SponsorTime } from "./types";

interface BaseMessage {
    from?: string;
}

interface DefaultMessage {
    message: 
        "update"
        | "sponsorStart"
        | "isInfoFound"
        | "getVideoID"
        | "getChannelID"
        | "isChannelWhitelisted"
        | "submitTimes";
}

interface BoolValueMessage {
    message: "whitelistChange";
    value: boolean;
}

export type Message = BaseMessage & (DefaultMessage | BoolValueMessage);

interface IsInfoFoundMessageResponse {
    found: boolean;
    sponsorTimes: SponsorTime[];
}

interface GetVideoIdResponse {
    videoID: string;
}

interface GetChannelIDResponse {
    channelID: string;
}

interface SponsorStartResponse {
    creatingSegment: boolean;
}

interface IsChannelWhitelistedResponse {
    value: boolean;
}

export type MessageResponse = 
    IsInfoFoundMessageResponse
    | GetVideoIdResponse
    | GetChannelIDResponse
    | SponsorStartResponse
    | IsChannelWhitelistedResponse;