AlwaysExpandProfiles & APSP: Fully Fix Conflict
This commit is contained in:
parent
d96f414d3e
commit
43fcaec5f9
3 changed files with 12 additions and 11 deletions
|
|
@ -7,7 +7,6 @@
|
|||
import { Devs } from "@utils/constants";
|
||||
import { openUserProfile } from "@utils/discord";
|
||||
import definePlugin from "@utils/types";
|
||||
import { User } from "@vencord/discord-types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "AlwaysExpandProfiles",
|
||||
|
|
@ -17,13 +16,13 @@ export default definePlugin({
|
|||
{
|
||||
find: '"view-profile"',
|
||||
replacement: {
|
||||
match: /(user:(\i).*?"PRESS_VIEW_PROFILE".{0,200}return)/,
|
||||
replace: "$1 $self.openUserModal($2);"
|
||||
match: /("PRESS_VIEW_PROFILE".{0,200})return(?<=userId:(\i\.id).*?)/,
|
||||
replace: "$1return $self.openUserModal($2);"
|
||||
},
|
||||
all: true
|
||||
},
|
||||
],
|
||||
openUserModal(user: User) {
|
||||
openUserProfile(user.id);
|
||||
openUserModal(userId: string) {
|
||||
openUserProfile(userId);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import alwaysExpandProfiles from "@equicordplugins/alwaysExpandProfiles";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getCurrentChannel } from "@utils/discord";
|
||||
import { fetchUserProfile, getCurrentChannel } from "@utils/discord";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { User } from "@vencord/discord-types";
|
||||
import { findComponentByCodeLazy } from "@webpack";
|
||||
|
|
@ -38,10 +38,12 @@ const AccountPanelContextMenu = ErrorBoundary.wrap(() => {
|
|||
id="vc-ap-view-alternate-popout"
|
||||
label={prioritizeServerProfile ? "View Account Profile" : "View Server Profile"}
|
||||
disabled={getCurrentChannel()?.getGuildId() == null}
|
||||
action={e => {
|
||||
action={async e => {
|
||||
if (isPluginEnabled(alwaysExpandProfiles.name)) {
|
||||
const user = UserStore.getCurrentUser();
|
||||
return alwaysExpandProfiles.openUserModal(user);
|
||||
const user = await fetchUserProfile(UserStore.getCurrentUser().id, {
|
||||
guild_id: getCurrentChannel()?.getGuildId()
|
||||
}, false);
|
||||
return alwaysExpandProfiles.openUserModal(user!.userId);
|
||||
}
|
||||
openAlternatePopout = true;
|
||||
accountPanelRef.current?.click();
|
||||
|
|
|
|||
|
|
@ -207,9 +207,9 @@ interface FetchUserProfileOptions {
|
|||
/**
|
||||
* Fetch a user's profile
|
||||
*/
|
||||
export async function fetchUserProfile(id: string, options?: FetchUserProfileOptions) {
|
||||
export async function fetchUserProfile(id: string, options?: FetchUserProfileOptions, cache = true) {
|
||||
const cached = UserProfileStore.getUserProfile(id);
|
||||
if (cached) return cached;
|
||||
if (cached && cache) return cached;
|
||||
|
||||
FluxDispatcher.dispatch({ type: "USER_PROFILE_FETCH_START", userId: id });
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue