47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
// Metro module 6174 (f6175).
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import RelationshipStore from "../../stores/RelationshipStore";
|
|
import UserStore from "../../stores/UserStore";
|
|
import { AutocompleterResultTypes } from "./AutocompleterConstants";
|
|
import { ChannelTypes } from "../../Constants";
|
|
import { computeChannelName } from "../channel/useChannelName";
|
|
export default function createAutocompleterResultForChannelId(a0, r7 = ChannelStore, r5 = UserStore, r4 = RelationshipStore) {
|
|
const channel = r7.getChannel(a0);
|
|
if (channel == null) {
|
|
return null;
|
|
}
|
|
const comparator = computeChannelName(channel, r5, r4);
|
|
const type = channel.type;
|
|
if (ChannelTypes.DM === type) {
|
|
const user = r5.getUser(channel.getRecipientId());
|
|
return user == null ? null : {
|
|
type: AutocompleterResultTypes.USER,
|
|
record: user,
|
|
score: 0,
|
|
comparator
|
|
};
|
|
}
|
|
if (ChannelTypes.GROUP_DM === type) {
|
|
return {
|
|
type: AutocompleterResultTypes.GROUP_DM,
|
|
record: channel,
|
|
score: 0,
|
|
comparator
|
|
};
|
|
}
|
|
if (ChannelTypes.GUILD_VOICE !== type && ChannelTypes.GUILD_STAGE_VOICE !== type) {
|
|
return {
|
|
type: AutocompleterResultTypes.TEXT_CHANNEL,
|
|
record: channel,
|
|
score: 0,
|
|
comparator
|
|
};
|
|
}
|
|
return {
|
|
type: AutocompleterResultTypes.VOICE_CHANNEL,
|
|
record: channel,
|
|
score: 0,
|
|
comparator
|
|
};
|
|
};
|