Fix Channel Tabs

This commit is contained in:
thororen1234 2024-09-25 17:10:47 -04:00
parent c4ba86345b
commit 22a755b25d
4 changed files with 10 additions and 9 deletions

View file

@ -8,8 +8,9 @@ import { classNameFactory } from "@api/Styles";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import { closeModal, openModal } from "@utils/modal"; import { closeModal, openModal } from "@utils/modal";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { Avatar, ChannelStore, ContextMenuApi, FluxDispatcher, GuildStore, i18n, Menu, ReadStateStore, ReadStateUtils, Text, Tooltip, useDrag, useDrop, useEffect, useRef, UserStore } from "@webpack/common"; import { Avatar, ChannelStore, ContextMenuApi, FluxDispatcher, GuildStore, i18n, Menu, ReadStateStore, Text, Tooltip, useDrag, useDrop, useEffect, useRef, UserStore } from "@webpack/common";
import { ackChannel } from "..";
import { BasicChannelTabsProps, Bookmark, BookmarkFolder, BookmarkProps, CircleQuestionIcon, isBookmarkFolder, settings, switchChannel, useBookmarks } from "../util"; import { BasicChannelTabsProps, Bookmark, BookmarkFolder, BookmarkProps, CircleQuestionIcon, isBookmarkFolder, settings, switchChannel, useBookmarks } from "../util";
import { NotificationDot } from "./ChannelTab"; import { NotificationDot } from "./ChannelTab";
import { BookmarkContextMenu, EditModal } from "./ContextMenus"; import { BookmarkContextMenu, EditModal } from "./ContextMenus";
@ -110,7 +111,7 @@ function BookmarkFolderOpenMenu(props: BookmarkProps) {
id="mark-as-read" id="mark-as-read"
label={i18n.Messages.MARK_AS_READ} label={i18n.Messages.MARK_AS_READ}
disabled={!ReadStateStore.hasUnread(b.channelId)} disabled={!ReadStateStore.hasUnread(b.channelId)}
action={() => ReadStateUtils.ackChannel(ChannelStore.getChannel(b.channelId))} action={() => ackChannel(ChannelStore.getChannel(b.channelId))}
/> />
</Menu.MenuGroup> </Menu.MenuGroup>
), ),

View file

@ -6,8 +6,9 @@
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
import { Button, ChannelStore, FluxDispatcher, Forms, i18n, Menu, ReadStateStore, ReadStateUtils, Select, Text, TextInput, useState } from "@webpack/common"; import { Button, ChannelStore, FluxDispatcher, Forms, i18n, Menu, ReadStateStore, Select, Text, TextInput, useState } from "@webpack/common";
import { ackChannel } from "..";
import { bookmarkFolderColors, bookmarkPlaceholderName, closeOtherTabs, closeTab, closeTabsToTheLeft, closeTabsToTheRight, createTab, hasClosedTabs, isBookmarkFolder, openedTabs, reopenClosedTab, settings, toggleCompactTab } from "../util"; import { bookmarkFolderColors, bookmarkPlaceholderName, closeOtherTabs, closeTab, closeTabsToTheLeft, closeTabsToTheRight, createTab, hasClosedTabs, isBookmarkFolder, openedTabs, reopenClosedTab, settings, toggleCompactTab } from "../util";
import { Bookmark, BookmarkFolder, Bookmarks, ChannelTabsProps, UseBookmarkMethods } from "../util/types"; import { Bookmark, BookmarkFolder, Bookmarks, ChannelTabsProps, UseBookmarkMethods } from "../util/types";
@ -179,7 +180,7 @@ export function BookmarkContextMenu({ bookmarks, index, methods }: { bookmarks:
id="mark-as-read" id="mark-as-read"
label={i18n.Messages.MARK_AS_READ} label={i18n.Messages.MARK_AS_READ}
disabled={!ReadStateStore.hasUnread(bookmark.channelId)} disabled={!ReadStateStore.hasUnread(bookmark.channelId)}
action={() => ReadStateUtils.ackChannel(ChannelStore.getChannel(bookmark.channelId))} action={() => ackChannel(ChannelStore.getChannel(bookmark.channelId))}
/> />
} }
{isFolder {isFolder
@ -289,7 +290,7 @@ export function TabContextMenu({ tab }: { tab: ChannelTabsProps; }) {
id="mark-as-read" id="mark-as-read"
label={i18n.Messages.MARK_AS_READ} label={i18n.Messages.MARK_AS_READ}
disabled={!ReadStateStore.hasUnread(channel.id)} disabled={!ReadStateStore.hasUnread(channel.id)}
action={() => ReadStateUtils.ackChannel(channel)} action={() => ackChannel(channel)}
/> />
} }
<Menu.MenuCheckboxItem <Menu.MenuCheckboxItem

View file

@ -10,6 +10,7 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs, EquicordDevs } from "@utils/constants"; import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { findByCodeLazy } from "@webpack";
import { ChannelStore, Menu } from "@webpack/common"; import { ChannelStore, Menu } from "@webpack/common";
import { Channel, Message } from "discord-types/general"; import { Channel, Message } from "discord-types/general";
@ -17,6 +18,8 @@ import ChannelsTabsContainer from "./components/ChannelTabsContainer";
import { BasicChannelTabsProps, createTab, settings } from "./util"; import { BasicChannelTabsProps, createTab, settings } from "./util";
import * as ChannelTabsUtils from "./util"; import * as ChannelTabsUtils from "./util";
export const ackChannel = findByCodeLazy(".getActiveJoinedThreadsForParent(", "isForumLikeChannel()");
const contextMenuPatch: NavContextMenuPatchCallback = (children, props: { channel: Channel, messageId?: string; }) => const contextMenuPatch: NavContextMenuPatchCallback = (children, props: { channel: Channel, messageId?: string; }) =>
() => { () => {
const { channel, messageId } = props; const { channel, messageId } = props;

View file

@ -172,10 +172,6 @@ export const InviteActions = findByPropsLazy("resolveInvite");
export const IconUtils: t.IconUtils = findByPropsLazy("getGuildBannerURL", "getUserAvatarURL"); export const IconUtils: t.IconUtils = findByPropsLazy("getGuildBannerURL", "getUserAvatarURL");
export const ReadStateUtils = mapMangledModuleLazy('type:"ENABLE_AUTOMATIC_ACK",', {
ackChannel: filters.byCode(".getActiveJoinedThreadsForParent(")
});
export const ExpressionPickerStore: t.ExpressionPickerStore = mapMangledModuleLazy("expression-picker-last-active-view", { export const ExpressionPickerStore: t.ExpressionPickerStore = mapMangledModuleLazy("expression-picker-last-active-view", {
openExpressionPicker: filters.byCode(/setState\({activeView:(?:(?!null)\i),activeViewType:/), openExpressionPicker: filters.byCode(/setState\({activeView:(?:(?!null)\i),activeViewType:/),
closeExpressionPicker: filters.byCode("setState({activeView:null"), closeExpressionPicker: filters.byCode("setState({activeView:null"),