50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
// Metro module 15176 (f15177).
|
|
import { memo, useCallback } from "react";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildChannelStore from "../../../stores/GuildChannelStore";
|
|
import { CHANNEL_MARGIN_VERTICAL } from "../../channel_list_v2/native/RedesignChannelListConstants";
|
|
import { UnreadSetting } from "../../read_states/ReadStateConstants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
|
|
import { transitionToGuild } from "../../routing/router_utils";
|
|
import { openChannelLongPressActionSheet } from "../../channel/native/openChannelLongPressActionSheet";
|
|
import ChannelItem from "./ChannelItem";
|
|
import getChannelA11yLabel from "../../channel/getChannelA11yLabel";
|
|
const useStyles = createStyles({
|
|
container: {
|
|
marginVertical: CHANNEL_MARGIN_VERTICAL,
|
|
marginHorizontal: 8,
|
|
borderRadius: Module712.radii.md
|
|
}
|
|
});
|
|
const r40 = memo(function(a0) {
|
|
let id;
|
|
const { guildId, selectedChannelId } = a0;
|
|
let selected = a0.selected;
|
|
id = void 0;
|
|
const styles = useStyles();
|
|
const stateFromStores = useStateFromStores([ChannelStore, GuildChannelStore], () => {
|
|
const directoryChannelIds = GuildChannelStore.getDirectoryChannelIds(guildId);
|
|
return directoryChannelIds.length !== 0 ? ChannelStore.getChannel(directoryChannelIds[0]) : null;
|
|
});
|
|
id = stateFromStores?.id;
|
|
if (!selected) {
|
|
selected = id === selectedChannelId;
|
|
}
|
|
const callback = useCallback(() => {
|
|
transitionToGuild(guildId, id);
|
|
}, [guildId, id]);
|
|
const callback2 = useCallback(() => {
|
|
if (id != null) {
|
|
openChannelLongPressActionSheet(id);
|
|
}
|
|
}, [id]);
|
|
return stateFromStores == null ? null : <ChannelItem onPress={callback} onLongPress={callback2} style={styles.container} accessible accessibilityRole="button" accessibilityLabel={getChannelA11yLabel({
|
|
channel: stateFromStores
|
|
})} accessibilityState={{
|
|
selected
|
|
}} channel={stateFromStores} selected={selected} resolvedUnreadSetting={UnreadSetting.ONLY_MENTIONS} />;
|
|
});
|
|
export default r40;
|