mirror of
https://github.com/Vendicated/Vencord
synced 2024-09-13 04:29:24 -04:00
SimplifiedProfileNotes: Fix for update + bot profiles + icon is now hidden while loading + fix clearing note will hide box on next open as if empty
This commit is contained in:
parent
b5b7627d76
commit
f7311ec063
1 changed files with 14 additions and 9 deletions
|
@ -28,6 +28,7 @@ const settings = definePluginSettings({
|
|||
|
||||
type NoteHook = {
|
||||
visible: boolean;
|
||||
loading: boolean;
|
||||
autoFocus: boolean;
|
||||
note: string;
|
||||
activate: () => void;
|
||||
|
@ -40,10 +41,13 @@ type NotesSectionProps = {
|
|||
|
||||
function useNoteBox(userId: string): NoteHook {
|
||||
const { note, loading } = useNote(userId);
|
||||
const [forced, setForced] = useState(!settings.store.hideWhenEmpty);
|
||||
const hasNote = !loading && (typeof note === "string" && note?.length > 0);
|
||||
const [forced, setForced] = useState(!settings.store.hideWhenEmpty || hasNote);
|
||||
const [autoFocus, setAutoFocus] = useState(false);
|
||||
if (hasNote && !forced) setForced(true);
|
||||
return {
|
||||
visible: forced || (!loading && note !== undefined),
|
||||
visible: forced || hasNote,
|
||||
loading,
|
||||
autoFocus,
|
||||
note,
|
||||
activate() {
|
||||
|
@ -81,7 +85,8 @@ export default definePlugin({
|
|||
patches: [
|
||||
{
|
||||
// Popout
|
||||
find: /\.BITE_SIZE,onOpenProfile:\i,usernameIcon:/,
|
||||
find: /\.BITE_SIZE,onOpenProfile:\i,/,
|
||||
all: true,
|
||||
replacement: {
|
||||
match: /currentUser:\i,guild:\i,onOpenProfile:.+?}\)(?=])(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
||||
replace: "$&,$self.NotesSection({ user: $1, ...vencordNotesHook })"
|
||||
|
@ -91,8 +96,8 @@ export default definePlugin({
|
|||
// DM Sidebar
|
||||
find: /getRelationshipType.{0,800}\.Overlay.{0,200}Messages\.USER_POPOUT_ABOUT_ME/,
|
||||
replacement: {
|
||||
match: /(\(0,.{0,50}Messages\.USER_PROFILE_MEMBER_SINCE.{0,100}userId:(\i)\.id}\)\}\))]/,
|
||||
replace: "$1,$self.NotesSection({ headingColor: 'header-primary', user: $2, ...vencordNotesHook })]"
|
||||
match: /(\(0,.{0,50}?Messages\.USER_PROFILE_MEMBER_SINCE.{0,100}?userId:(\i)\.id}\)\}\))/,
|
||||
replace: "$1,$self.NotesSection({ headingColor: 'header-primary', user: $2, ...vencordNotesHook })"
|
||||
}
|
||||
}
|
||||
].map(p => ({
|
||||
|
@ -100,12 +105,12 @@ export default definePlugin({
|
|||
group: true,
|
||||
replacement: [
|
||||
{
|
||||
match: /getRelationshipType\((\i.id)\)\)/,
|
||||
replace: "$&,vencordNotesHook=$self.useNoteBox($1)"
|
||||
match: /hidePersonalInformation\)/,
|
||||
replace: "$&,vencordNotesHook=$self.useNoteBox(arguments[0].user.id)"
|
||||
},
|
||||
{
|
||||
match: /(!\i)(&&\(0,\i\.jsx\)\(\i\.\i,{user:\i,isHovering:\i,onOpenProfile:\(\)=>).{1,20}?\({subsection:\i\.\i\.NOTE}\)/,
|
||||
replace: "($1&&!vencordNotesHook.visible)$2vencordNotesHook.activate()"
|
||||
match: /(!\i)(&&\(0,\i\.jsx\)\(\i\.\i,{userId:\i\.id,isHovering:\i,onOpenProfile:)\i/,
|
||||
replace: "($1&&!vencordNotesHook.visible&&!vencordNotesHook.loading)$2()=>vencordNotesHook.activate()"
|
||||
},
|
||||
p.replacement
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue