chore: change for better type inference

This commit is contained in:
Lhcfl 2024-04-04 00:11:58 +08:00
parent add6081f18
commit 435260e197
1 changed files with 20 additions and 17 deletions

View File

@ -174,6 +174,25 @@ if (props.src === "antenna") {
const stream = useStream();
function connectChannel() {
if (props.src === "mentions") {
connection = stream.useChannel("main");
connection.on("mention", prepend);
return;
}
if (props.src === "directs") {
const onNote = (note) => {
if (note.visibility === "specified") {
prepend(note);
}
};
connection = stream.useChannel("main");
connection.on("mention", onNote);
return;
}
if (props.src === "file") {
return;
}
if (props.src === "antenna") {
connection = stream.useChannel("antenna", {
antennaId: props.antenna!,
@ -199,17 +218,6 @@ function connectChannel() {
connection = stream.useChannel("globalTimeline", {
withReplies: defaultStore.state.showTimelineReplies,
});
} else if (props.src === "mentions") {
connection = stream.useChannel("main");
connection.on("mention", prepend);
} else if (props.src === "directs") {
const onNote = (note) => {
if (note.visibility === "specified") {
prepend(note);
}
};
connection = stream.useChannel("main");
connection.on("mention", onNote);
} else if (props.src === "list") {
connection = stream.useChannel("userList", {
listId: props.list,
@ -219,12 +227,7 @@ function connectChannel() {
channelId: props.channel,
});
}
if (
props.src !== "directs" &&
props.src !== "mentions" &&
props.src !== "file"
)
connection.on("note", prepend);
connection.on("note", prepend);
}
provide(