mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-29 16:34:25 -04:00
Fix HolyNotes
This commit is contained in:
parent
04a6472e0a
commit
4cd4e44378
4 changed files with 10 additions and 11 deletions
|
@ -60,7 +60,7 @@ interface PluginModalProps extends ModalProps {
|
||||||
onRestartNeeded(): void;
|
onRestartNeeded(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeDummyUser(user: { username: string; id?: string; avatar?: string; }) {
|
export function makeDummyUser(user: { username: string; id?: string; avatar?: string; }) {
|
||||||
const newUser = new UserRecord({
|
const newUser = new UserRecord({
|
||||||
username: user.username,
|
username: user.username,
|
||||||
id: user.id ?? generateId(),
|
id: user.id ?? generateId(),
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { makeDummyUser } from "@components/PluginSettings/PluginModal";
|
||||||
import { ChannelStore, lodash, Toasts, UserStore } from "@webpack/common";
|
import { ChannelStore, lodash, Toasts, UserStore } from "@webpack/common";
|
||||||
import { Channel, Message } from "discord-types/general";
|
import { Channel, Message } from "discord-types/general";
|
||||||
|
|
||||||
import { User } from ".";
|
|
||||||
import { Discord, HolyNotes } from "./types";
|
import { Discord, HolyNotes } from "./types";
|
||||||
import { deleteCacheFromDataStore, DeleteEntireStore, saveCacheToDataStore } from "./utils";
|
import { deleteCacheFromDataStore, DeleteEntireStore, saveCacheToDataStore } from "./utils";
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ export default new (class NoteHandler {
|
||||||
for (const notebook in notebooks)
|
for (const notebook in notebooks)
|
||||||
for (const noteId in notebooks[notebook]) {
|
for (const noteId in notebooks[notebook]) {
|
||||||
const note = notebooks[notebook][noteId];
|
const note = notebooks[notebook][noteId];
|
||||||
const user = UserStore.getUser(note.author.id) ?? new User({ ...note.author });
|
const user = UserStore.getUser(note.author.id) ?? makeDummyUser(note.author);
|
||||||
|
|
||||||
Object.assign(notebooks[notebook][noteId].author, {
|
Object.assign(notebooks[notebook][noteId].author, {
|
||||||
avatar: user.avatar,
|
avatar: user.avatar,
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Channel, cozyMessage, groupStart, message, MessageType, User } from "@equicordplugins/holyNotes";
|
import { makeDummyUser } from "@components/PluginSettings/PluginModal";
|
||||||
|
import { MessageType } from "@equicordplugins/holyNotes";
|
||||||
import { copyToClipboard } from "@utils/clipboard";
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { ModalProps } from "@utils/modal";
|
import { ModalProps } from "@utils/modal";
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
import { findByCodeLazy, findByProps, findComponentByCodeLazy } from "@webpack";
|
||||||
import { ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common";
|
import { ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common";
|
||||||
|
|
||||||
import noteHandler from "../../NoteHandler";
|
import noteHandler from "../../NoteHandler";
|
||||||
import { HolyNotes } from "../../types";
|
import { HolyNotes } from "../../types";
|
||||||
|
|
||||||
|
|
||||||
export const RenderMessage = ({
|
export const RenderMessage = ({
|
||||||
note,
|
note,
|
||||||
notebook,
|
notebook,
|
||||||
|
@ -28,6 +28,8 @@ export const RenderMessage = ({
|
||||||
fromDeleteModal: boolean;
|
fromDeleteModal: boolean;
|
||||||
closeModal?: () => void;
|
closeModal?: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
|
const { message, groupStart, cozyMessage } = findByProps("cozyMessage");
|
||||||
|
const Channel = findByCodeLazy("computeLurkerPermissionsAllowList(){");
|
||||||
const ChannelMessage = findComponentByCodeLazy("Message must not be a thread");
|
const ChannelMessage = findComponentByCodeLazy("Message must not be a thread");
|
||||||
|
|
||||||
const [isHoldingDelete, setHoldingDelete] = React.useState(false);
|
const [isHoldingDelete, setHoldingDelete] = React.useState(false);
|
||||||
|
@ -91,7 +93,7 @@ export const RenderMessage = ({
|
||||||
Object.assign(
|
Object.assign(
|
||||||
{ ...note },
|
{ ...note },
|
||||||
{
|
{
|
||||||
author: new User({ ...note?.author }),
|
author: makeDummyUser(note?.author),
|
||||||
timestamp: new Date(note?.timestamp),
|
timestamp: new Date(note?.timestamp),
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
embeds: note?.embeds?.map((embed: { timestamp: string | number | Date; }) =>
|
embeds: note?.embeds?.map((embed: { timestamp: string | number | Date; }) =>
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { EquicordDevs } from "@utils/constants";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { openModal } from "@utils/modal";
|
import { openModal } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByCodeLazy, findByProps, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByCodeLazy, findByProps, findComponentByCodeLazy } from "@webpack";
|
||||||
import { ChannelStore, Menu } from "@webpack/common";
|
import { ChannelStore, Menu } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -35,10 +35,7 @@ import { NoteModal } from "./components/modals/Notebook";
|
||||||
import noteHandler, { noteHandlerCache } from "./NoteHandler";
|
import noteHandler, { noteHandlerCache } from "./NoteHandler";
|
||||||
import { DataStoreToCache, HolyNoteStore } from "./utils";
|
import { DataStoreToCache, HolyNoteStore } from "./utils";
|
||||||
|
|
||||||
export const User = findByCodeLazy("isSystemUser(){");
|
|
||||||
export const { message, groupStart, cozyMessage } = findByPropsLazy("cozyMessage");
|
|
||||||
export const MessageType = findByCodeLazy("isEdited(){");
|
export const MessageType = findByCodeLazy("isEdited(){");
|
||||||
export const Channel = findByCodeLazy("computeLurkerPermissionsAllowList(){");
|
|
||||||
|
|
||||||
const HeaderBarIcon = findComponentByCodeLazy(".HEADER_BAR_BADGE_TOP:", '.iconBadge,"top"');
|
const HeaderBarIcon = findComponentByCodeLazy(".HEADER_BAR_BADGE_TOP:", '.iconBadge,"top"');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue