mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 06:03:03 -04:00
Stable Fixes
This commit is contained in:
parent
16763a7cd4
commit
c17154e7cd
7 changed files with 5 additions and 83 deletions
|
@ -7,24 +7,10 @@
|
|||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Menu, NavigationRouter, Toasts } from "@webpack/common";
|
||||
const MessageStore = findByPropsLazy("getMessages", "getMessage");
|
||||
const ChannelStore = findByPropsLazy("getChannel", "getDMFromUserId");
|
||||
const UserStore = findByPropsLazy("getUser", "getCurrentUser");
|
||||
const MessageActions = findByPropsLazy("fetchMessages", "searchMessages");
|
||||
import { Menu, MessageActions, MessageStore, NavigationRouter, Toasts, UserStore } from "@webpack/common";
|
||||
|
||||
async function findLastMessageFromUser(channelId: string, userId: string) {
|
||||
try {
|
||||
|
||||
if (!MessageStore || !MessageActions) {
|
||||
Toasts.show({
|
||||
type: Toasts.Type.FAILURE,
|
||||
message: "Required Discord modules not found.",
|
||||
id: Toasts.genId()
|
||||
});
|
||||
return null;
|
||||
}
|
||||
const messageCollection = MessageStore.getMessages(channelId);
|
||||
let messages = messageCollection?.toArray() || [];
|
||||
let userMessage = messages.filter(m => m?.author?.id === userId).pop();
|
||||
|
@ -77,23 +63,7 @@ async function jumpToLastActive(channel: any, targetUserId?: string) {
|
|||
|
||||
userId = targetUserId;
|
||||
} else {
|
||||
if (!UserStore?.getCurrentUser) {
|
||||
Toasts.show({
|
||||
type: Toasts.Type.FAILURE,
|
||||
message: "Could not determine user. Try again later.",
|
||||
id: Toasts.genId()
|
||||
});
|
||||
return;
|
||||
}
|
||||
const currentUser = UserStore.getCurrentUser();
|
||||
if (!currentUser || !currentUser.id) {
|
||||
Toasts.show({
|
||||
type: Toasts.Type.FAILURE,
|
||||
message: "Could not determine current user. Try again later.",
|
||||
id: Toasts.genId()
|
||||
});
|
||||
return;
|
||||
}
|
||||
userId = currentUser.id;
|
||||
}
|
||||
const messageId = await findLastMessageFromUser(channelId, userId);
|
||||
|
|
|
@ -13,13 +13,6 @@ export default definePlugin({
|
|||
authors: [Devs.sadan, Devs.Nuckyz],
|
||||
description: "Allows you to omit either width or height when opening an image modal",
|
||||
patches: [
|
||||
{
|
||||
find: ".contain,SCALE_DOWN:",
|
||||
replacement: {
|
||||
match: /(?<="IMAGE"===\i\?)\i(?=\?)/,
|
||||
replace: "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".dimensionlessImage,",
|
||||
replacement: {
|
||||
|
|
|
@ -162,14 +162,6 @@ export default definePlugin({
|
|||
managedStyle,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: ".contain,SCALE_DOWN:",
|
||||
replacement: {
|
||||
match: /imageClassName:/,
|
||||
replace: `id:"${ELEMENT_ID}",$&`
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
find: ".dimensionlessImage,",
|
||||
replacement: [
|
||||
|
|
|
@ -85,7 +85,7 @@ export default definePlugin({
|
|||
find: ".USER_MENTION)",
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=onContextMenu:\i,color:)\i(?=\},\i\),\{children)(?<=user:(\i),channel:(\i).{0,500}?)/,
|
||||
match: /(?<=onContextMenu:\i,color:)\i(?=,onClick)(?<=user:(\i),channel:(\i).+?)/,
|
||||
replace: "$self.getColorInt($1?.id,$2?.id)",
|
||||
}
|
||||
],
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
|
||||
.vc-position-inherit {
|
||||
position: inherit;
|
||||
}
|
||||
|
||||
/**
|
||||
* copy pasted from discord css. not really webpack-findable since it's the only class in the module
|
||||
**/
|
||||
|
||||
.vc-image-modal {
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
@media(width <= 485px) {
|
||||
.vc-image-modal {
|
||||
overflow: visible;
|
||||
overflow: initial;
|
||||
}
|
||||
}
|
|
@ -143,9 +143,6 @@ export function sendMessage(
|
|||
*/
|
||||
export function openImageModal(item: Except<MediaModalItem, "type">, mediaModalProps?: Omit<MediaModalProps, "items">) {
|
||||
return openMediaModal({
|
||||
className: "vc-image-modal",
|
||||
fit: "vc-position-inherit",
|
||||
shouldAnimateCarousel: true,
|
||||
items: [{
|
||||
type: "IMAGE",
|
||||
original: item.original ?? item.url,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { filters, findModuleId, mapMangledModuleLazy, proxyLazyWebpack, wreq } from "@webpack";
|
||||
import { filters, findByCodeLazy, mapMangledModuleLazy } from "@webpack";
|
||||
import type { ComponentType, PropsWithChildren, ReactNode, Ref } from "react";
|
||||
|
||||
import { LazyComponent } from "./react";
|
||||
|
@ -138,16 +138,10 @@ export type MediaModalProps = {
|
|||
fit?: string;
|
||||
shouldRedactExplicitContent?: boolean;
|
||||
shouldHideMediaOptions?: boolean;
|
||||
shouldAnimateCarousel?: boolean;
|
||||
};
|
||||
|
||||
export const openMediaModal: (props: MediaModalProps) => void = proxyLazyWebpack(() => {
|
||||
const mediaModalKeyModuleId = findModuleId('"Zoomed Media Modal"');
|
||||
if (mediaModalKeyModuleId == null) return;
|
||||
|
||||
const openMediaModalModule = wreq(findModuleId(mediaModalKeyModuleId, "modalKey:") as any);
|
||||
return Object.values<any>(openMediaModalModule).find(v => String(v).includes("modalKey:"));
|
||||
});
|
||||
// modal key: "Media Viewer Modal"
|
||||
export const openMediaModal: (props: MediaModalProps) => void = findByCodeLazy("hasMediaOptions", "shouldHideMediaOptions");
|
||||
|
||||
interface ModalAPI {
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue