Add opening the user’s profile modal

This commit is contained in:
Samuel Elliott 2018-04-15 02:18:26 +01:00
parent 96952c3fef
commit e524c50b65
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 16 additions and 6 deletions

View File

@ -52,6 +52,7 @@ export const Modules = {
get PruneMembersModal() { return this._getModule('PruneMembersModal'); },
get NotificationSettingsModal() { return this._getModule('NotificationSettingsModal'); },
get PrivacySettingsModal() { return this._getModule('PrivacySettingsModal'); },
get UserProfileModal() { return this._getModule('UserProfileModal'); },
get DiscordPermissions() { return this.DiscordConstants.Permissions; }
};

View File

@ -189,7 +189,7 @@ const KnownModules = {
/* Modals */
ModalStack: Filters.byProperties(['push', 'update', 'pop', 'popWithKey']),
ConfirmModal: Filters.byPrototypeFields(['handleCancel', 'handleSubmit', 'handleMinorConfirm']),
UserProfileModals: Filters.byProperties(['fetchMutualFriends', 'setSection']),
UserProfileModal: Filters.byProperties(['fetchMutualFriends', 'setSection']),
ChangeNicknameModal: Filters.byProperties(['open', 'changeNickname']),
CreateChannelModal: Filters.byProperties(['open', 'createChannel']),
PruneMembersModal: Filters.byProperties(['open', 'prune']),

View File

@ -108,6 +108,15 @@ export class User {
Modules.RelationshipManager.removeRelationship(this.id, {location: 'Context Menu'});
}
/**
* Opens the profile modal for this user.
* @param {String} section The section to open (see DiscordConstants.UserProfileSections)
*/
openUserProfileModal(section = 'USER_INFO') {
Modules.UserProfileModal.open(this.id);
Modules.UserProfileModal.setSection(section);
}
}
const guild_members = new WeakMap();

View File

@ -22,7 +22,7 @@ export default class extends Module {
this.patchMessage();
this.patchChannelMember();
this.patchNameTag();
this.patchUserProfileModals();
this.patchUserProfileModal();
}
get contributors() {
@ -167,13 +167,13 @@ export default class extends Module {
}
/**
* Patches UserProfileModals to inject profile badges into the modal once opened.
* Patches UserProfileModal to inject profile badges into the modal once opened.
* TODO: just patch the modal component
*/
async patchUserProfileModals() {
const UserProfileModals = WebpackModules.getModuleByName('UserProfileModals');
async patchUserProfileModal() {
const UserProfileModal = WebpackModules.getModuleByName('UserProfileModal');
MonkeyPatch('BdUI', UserProfileModals).after('open', async (context, [userid]) => {
MonkeyPatch('BdUI', UserProfileModal).after('open', async (context, [userid]) => {
const c = contributors.find(c => c.id === userid);
if (!c) return;