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 { closeModal, openModal } from "@utils/modal";
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 { NotificationDot } from "./ChannelTab";
import { BookmarkContextMenu, EditModal } from "./ContextMenus";
@ -110,7 +111,7 @@ function BookmarkFolderOpenMenu(props: BookmarkProps) {
id="mark-as-read"
label={i18n.Messages.MARK_AS_READ}
disabled={!ReadStateStore.hasUnread(b.channelId)}
action={() => ReadStateUtils.ackChannel(ChannelStore.getChannel(b.channelId))}
action={() => ackChannel(ChannelStore.getChannel(b.channelId))}
/>
</Menu.MenuGroup>
),

View file

@ -6,8 +6,9 @@
import { Margins } from "@utils/margins";
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 { Bookmark, BookmarkFolder, Bookmarks, ChannelTabsProps, UseBookmarkMethods } from "../util/types";
@ -179,7 +180,7 @@ export function BookmarkContextMenu({ bookmarks, index, methods }: { bookmarks:
id="mark-as-read"
label={i18n.Messages.MARK_AS_READ}
disabled={!ReadStateStore.hasUnread(bookmark.channelId)}
action={() => ReadStateUtils.ackChannel(ChannelStore.getChannel(bookmark.channelId))}
action={() => ackChannel(ChannelStore.getChannel(bookmark.channelId))}
/>
}
{isFolder
@ -289,7 +290,7 @@ export function TabContextMenu({ tab }: { tab: ChannelTabsProps; }) {
id="mark-as-read"
label={i18n.Messages.MARK_AS_READ}
disabled={!ReadStateStore.hasUnread(channel.id)}
action={() => ReadStateUtils.ackChannel(channel)}
action={() => ackChannel(channel)}
/>
}
<Menu.MenuCheckboxItem

View file

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