More Bug Fixes
This commit is contained in:
parent
c12b5d59b0
commit
87e26a2ffc
6 changed files with 47 additions and 32 deletions
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import "./styles.css";
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { ModalCloseButton } from "@utils/modal";
|
||||
import { Message } from "@vencord/discord-types";
|
||||
|
|
@ -40,13 +42,6 @@ export default function ReplyNavigator({ replies }: { replies: Message[]; }) {
|
|||
<ErrorBoundary>
|
||||
<div ref={ref} className={containerStyles.containerBottom + " vc-findreply-div"} style={{
|
||||
display: visible ? "flex" : "none",
|
||||
backgroundColor: "var(--background-primary)",
|
||||
borderRadius: "3vmin",
|
||||
zIndex: 0,
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
paddingLeft: "1em",
|
||||
paddingRight: "1em"
|
||||
}}>
|
||||
<Paginator
|
||||
className={"vc-findreply-paginator"}
|
||||
|
|
|
|||
|
|
@ -97,10 +97,20 @@ export default definePlugin({
|
|||
message: "Use the bottom panel to navigate between replies.",
|
||||
type: Toasts.Type.MESSAGE
|
||||
});
|
||||
const container = document.querySelector("[class^=channelBottomBarArea_]");
|
||||
if (!container) {
|
||||
Toasts.show({
|
||||
id: Toasts.genId(),
|
||||
message: "Couldn't find the container element.",
|
||||
type: Toasts.Type.FAILURE
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!madeComponent) {
|
||||
madeComponent = true;
|
||||
element = document.createElement("div");
|
||||
document.querySelector("[class^=base_]")!.appendChild(element);
|
||||
container.appendChild(element);
|
||||
root = createRoot(element);
|
||||
}
|
||||
root!.render(<ReplyNavigator replies={replies} />);
|
||||
|
|
|
|||
|
|
@ -6,3 +6,10 @@
|
|||
align-items: inherit !important;
|
||||
line-height: 0 !important;
|
||||
}
|
||||
|
||||
.vc-findreply-div {
|
||||
background-color: var(--background-base-lower);
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
width: 270px;
|
||||
}
|
||||
|
|
@ -7,28 +7,18 @@
|
|||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Menu, MessageActions, MessageStore, NavigationRouter, Toasts, UserStore } from "@webpack/common";
|
||||
import { Menu, NavigationRouter, RestAPI, Toasts, UserStore } from "@webpack/common";
|
||||
|
||||
async function findLastMessageFromUser(channelId: string, userId: string) {
|
||||
async function findLastMessageFromUser(guildId: string, channelId: string, userId: string) {
|
||||
try {
|
||||
const messageCollection = MessageStore.getMessages(channelId);
|
||||
let messages = messageCollection?.toArray() || [];
|
||||
let userMessage = messages.filter(m => m?.author?.id === userId).pop();
|
||||
if (userMessage) return userMessage.id;
|
||||
try {
|
||||
await MessageActions.fetchMessages({
|
||||
channelId: channelId,
|
||||
limit: 50
|
||||
});
|
||||
const res = await RestAPI.get({
|
||||
url: `/guilds/${guildId}/messages/search?author_id=${userId}&channel_id=${channelId}&sort_by=timestamp&sort_order=desc&offset=0`
|
||||
});
|
||||
|
||||
const updatedCollection = MessageStore.getMessages(channelId);
|
||||
messages = updatedCollection?.toArray() || [];
|
||||
userMessage = messages.filter(m => m?.author?.id === userId).pop();
|
||||
const allMessages = res.body.messages?.flat() || [];
|
||||
const newestMessage = allMessages.find(msg => msg && msg.id);
|
||||
|
||||
if (userMessage) return userMessage.id;
|
||||
} catch (fetchError) {
|
||||
console.error("Error fetching messages:", fetchError);
|
||||
}
|
||||
if (newestMessage) return newestMessage.id;
|
||||
|
||||
Toasts.show({
|
||||
type: Toasts.Type.FAILURE,
|
||||
|
|
@ -46,6 +36,7 @@ async function findLastMessageFromUser(channelId: string, userId: string) {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function jumpToLastActive(channel: any, targetUserId?: string) {
|
||||
try {
|
||||
if (!channel) {
|
||||
|
|
@ -66,7 +57,7 @@ async function jumpToLastActive(channel: any, targetUserId?: string) {
|
|||
const currentUser = UserStore.getCurrentUser();
|
||||
userId = currentUser.id;
|
||||
}
|
||||
const messageId = await findLastMessageFromUser(channelId, userId);
|
||||
const messageId = await findLastMessageFromUser(guildId, channelId, userId);
|
||||
if (messageId) {
|
||||
const url = `/channels/${guildId}/${channelId}/${messageId}`;
|
||||
NavigationRouter.transitionTo(url);
|
||||
|
|
@ -106,6 +97,7 @@ const UserContextMenuPatch: NavContextMenuPatchCallback = (children, { user, cha
|
|||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export function UserLastActiveIcon() {
|
||||
return (
|
||||
<svg
|
||||
|
|
@ -139,6 +131,7 @@ export function LastActiveIcon() {
|
|||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "LastActive",
|
||||
description: "A plugin to jump to last active message from yourself or another user in a channel/server.",
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ const settings = definePluginSettings({
|
|||
{
|
||||
label: "Only when clicking on a text box",
|
||||
value: "direct"
|
||||
},
|
||||
{
|
||||
label: "Never",
|
||||
value: "never"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -87,16 +91,22 @@ function blockPastePropogation(e: ClipboardEvent) {
|
|||
|
||||
function disablePasteOnMousedown(e: MouseEvent) {
|
||||
if (e.button !== 1) return;
|
||||
let testEl;
|
||||
let testEl: HTMLElement | null = null;
|
||||
|
||||
switch (settings.store.limitTo) {
|
||||
case "active":
|
||||
testEl = document.activeElement;
|
||||
testEl = document.activeElement as HTMLElement;
|
||||
break;
|
||||
case "direct":
|
||||
testEl = e.target;
|
||||
testEl = e.target as HTMLElement;
|
||||
break;
|
||||
case "never":
|
||||
testEl = null;
|
||||
break;
|
||||
}
|
||||
if (maybeEditable(testEl as HTMLElement | null)) return;
|
||||
|
||||
if (settings.store.limitTo !== "never" && maybeEditable(testEl)) return;
|
||||
|
||||
window.clearTimeout(timeoutID);
|
||||
pasteDisabled = true;
|
||||
timeoutID = window.setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ export const settings = definePluginSettings({
|
|||
permanentlyRemoveLogByDefault: {
|
||||
default: false,
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Vencord's base MessageLogger remove log button wiil delete logs permanently",
|
||||
description: "Vencord's base MessageLogger remove log button will delete logs permanently",
|
||||
},
|
||||
|
||||
ShowLogsButton: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue