mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +00:00
add guilds
This commit is contained in:
parent
231d3153ae
commit
191b637862
1 changed files with 44 additions and 5 deletions
|
@ -38,7 +38,6 @@ import { Channel, Guild, User } from "discord-types/general";
|
||||||
|
|
||||||
const cl = classNameFactory("vc-search-modal-");
|
const cl = classNameFactory("vc-search-modal-");
|
||||||
|
|
||||||
// TODO make guilds work
|
|
||||||
// FIXME fix the no Result display
|
// FIXME fix the no Result display
|
||||||
|
|
||||||
const SearchBarModule = findByPropsLazy("SearchBar", "Checkbox", "AvatarSizes");
|
const SearchBarModule = findByPropsLazy("SearchBar", "Checkbox", "AvatarSizes");
|
||||||
|
@ -340,6 +339,23 @@ export default function SearchModal({ modalProps, onSubmit, input, searchType =
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateGuildItem(guild: Guild, otherProps: UnspecificRowProps) {
|
||||||
|
const guildName = guild.name;
|
||||||
|
const guildIcon = guild.getIconURL(SearchBarModule.AvatarSizes.SIZE_32, false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Row {...otherProps}
|
||||||
|
icon={<SearchBarModule.Avatar
|
||||||
|
src={guildIcon}
|
||||||
|
size={SearchBarModule.AvatarSizes.SIZE_32}
|
||||||
|
aria-hidden={true}
|
||||||
|
/>}
|
||||||
|
label={guildName}
|
||||||
|
subLabel={""}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function generateGdmItem(channel: Channel, otherProps: UnspecificRowProps) {
|
function generateGdmItem(channel: Channel, otherProps: UnspecificRowProps) {
|
||||||
function getParticipants(channel: Channel) {
|
function getParticipants(channel: Channel) {
|
||||||
const userNames = channel.recipients
|
const userNames = channel.recipients
|
||||||
|
@ -490,10 +506,19 @@ export default function SearchModal({ modalProps, onSubmit, input, searchType =
|
||||||
|
|
||||||
loadFunction();
|
loadFunction();
|
||||||
|
|
||||||
const frequentChannels = wrapperFn([FrequencyModule], () => FrequencyModule.getFrequentlyWithoutFetchingLatest());
|
const frequentChannels: Channel[] = wrapperFn([FrequencyModule], () => FrequencyModule.getFrequentlyWithoutFetchingLatest());
|
||||||
const hasQuery = query !== "";
|
const hasQuery = query !== "";
|
||||||
|
|
||||||
function getItem(e: DestinationItem): Result {
|
function getItem(e: DestinationItem): Result {
|
||||||
|
if (e.type === "guild") {
|
||||||
|
const guild = GuildStore.getGuild(e.id);
|
||||||
|
return {
|
||||||
|
type: TextTypes.GUILD,
|
||||||
|
record: guild,
|
||||||
|
score: 0,
|
||||||
|
comparator: guild.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
if (e.type !== "user")
|
if (e.type !== "user")
|
||||||
return convertItem(e.id);
|
return convertItem(e.id);
|
||||||
{
|
{
|
||||||
|
@ -537,10 +562,22 @@ export default function SearchModal({ modalProps, onSubmit, input, searchType =
|
||||||
if (hasQuery) return filterItems(results);
|
if (hasQuery) return filterItems(results);
|
||||||
|
|
||||||
const channelHistory: string[] = FrequentsModule.getChannelHistory();
|
const channelHistory: string[] = FrequentsModule.getChannelHistory();
|
||||||
|
const guilds = Object.values(GuildStore.getGuilds()).map(
|
||||||
|
guild => {
|
||||||
|
if (guild == null) return;
|
||||||
|
return {
|
||||||
|
type: TextTypes.GUILD,
|
||||||
|
record: guild,
|
||||||
|
score: 0,
|
||||||
|
comparator: guild.name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const recentDestinations = filterItems([
|
const recentDestinations = filterItems([
|
||||||
...(channelHistory.length > 0 ? channelHistory.map(e => convertItem(e)) : []),
|
...(channelHistory.length > 0 ? channelHistory.map(e => convertItem(e)) : []),
|
||||||
...(frequentChannels.length > 0 ? frequentChannels.map(e => convertItem(e.id)) : [])
|
...(frequentChannels.length > 0 ? frequentChannels.map(e => convertItem(e.id)) : []),
|
||||||
|
...guilds
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return removeDuplicates(
|
return removeDuplicates(
|
||||||
|
@ -605,9 +642,11 @@ export default function SearchModal({ modalProps, onSubmit, input, searchType =
|
||||||
return generateUserItem(record, rowProps);
|
return generateUserItem(record, rowProps);
|
||||||
if (type === "GROUP_DM")
|
if (type === "GROUP_DM")
|
||||||
return generateGdmItem(record, rowProps);
|
return generateGdmItem(record, rowProps);
|
||||||
if (type === "TEXT_CHANNEL" || type === "VOICE_CHANNEL") {
|
if (type === "TEXT_CHANNEL" || type === "VOICE_CHANNEL")
|
||||||
return generateChannelItem(record, rowProps);
|
return generateChannelItem(record, rowProps);
|
||||||
} else throw new Error("Unknown type " + type);
|
if (type === "GUILD")
|
||||||
|
return generateGuildItem(record, rowProps);
|
||||||
|
else throw new Error("Unknown type " + type);
|
||||||
}, [results, selectedDestinationKeys, handleToggleDestination]);
|
}, [results, selectedDestinationKeys, handleToggleDestination]);
|
||||||
const navRef = useRef(null);
|
const navRef = useRef(null);
|
||||||
const nav = createNavigator(cl("search-modal"), navRef);
|
const nav = createNavigator(cl("search-modal"), navRef);
|
||||||
|
|
Loading…
Add table
Reference in a new issue