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 = {
|
type NoteHook = {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
loading: boolean;
|
||||||
autoFocus: boolean;
|
autoFocus: boolean;
|
||||||
note: string;
|
note: string;
|
||||||
activate: () => void;
|
activate: () => void;
|
||||||
|
@ -40,10 +41,13 @@ type NotesSectionProps = {
|
||||||
|
|
||||||
function useNoteBox(userId: string): NoteHook {
|
function useNoteBox(userId: string): NoteHook {
|
||||||
const { note, loading } = useNote(userId);
|
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);
|
const [autoFocus, setAutoFocus] = useState(false);
|
||||||
|
if (hasNote && !forced) setForced(true);
|
||||||
return {
|
return {
|
||||||
visible: forced || (!loading && note !== undefined),
|
visible: forced || hasNote,
|
||||||
|
loading,
|
||||||
autoFocus,
|
autoFocus,
|
||||||
note,
|
note,
|
||||||
activate() {
|
activate() {
|
||||||
|
@ -81,7 +85,8 @@ export default definePlugin({
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
// Popout
|
// Popout
|
||||||
find: /\.BITE_SIZE,onOpenProfile:\i,usernameIcon:/,
|
find: /\.BITE_SIZE,onOpenProfile:\i,/,
|
||||||
|
all: true,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /currentUser:\i,guild:\i,onOpenProfile:.+?}\)(?=])(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
match: /currentUser:\i,guild:\i,onOpenProfile:.+?}\)(?=])(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
||||||
replace: "$&,$self.NotesSection({ user: $1, ...vencordNotesHook })"
|
replace: "$&,$self.NotesSection({ user: $1, ...vencordNotesHook })"
|
||||||
|
@ -91,8 +96,8 @@ export default definePlugin({
|
||||||
// DM Sidebar
|
// DM Sidebar
|
||||||
find: /getRelationshipType.{0,800}\.Overlay.{0,200}Messages\.USER_POPOUT_ABOUT_ME/,
|
find: /getRelationshipType.{0,800}\.Overlay.{0,200}Messages\.USER_POPOUT_ABOUT_ME/,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(\(0,.{0,50}Messages\.USER_PROFILE_MEMBER_SINCE.{0,100}userId:(\i)\.id}\)\}\))]/,
|
match: /(\(0,.{0,50}?Messages\.USER_PROFILE_MEMBER_SINCE.{0,100}?userId:(\i)\.id}\)\}\))/,
|
||||||
replace: "$1,$self.NotesSection({ headingColor: 'header-primary', user: $2, ...vencordNotesHook })]"
|
replace: "$1,$self.NotesSection({ headingColor: 'header-primary', user: $2, ...vencordNotesHook })"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
].map(p => ({
|
].map(p => ({
|
||||||
|
@ -100,12 +105,12 @@ export default definePlugin({
|
||||||
group: true,
|
group: true,
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /getRelationshipType\((\i.id)\)\)/,
|
match: /hidePersonalInformation\)/,
|
||||||
replace: "$&,vencordNotesHook=$self.useNoteBox($1)"
|
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}\)/,
|
match: /(!\i)(&&\(0,\i\.jsx\)\(\i\.\i,{userId:\i\.id,isHovering:\i,onOpenProfile:)\i/,
|
||||||
replace: "($1&&!vencordNotesHook.visible)$2vencordNotesHook.activate()"
|
replace: "($1&&!vencordNotesHook.visible&&!vencordNotesHook.loading)$2()=>vencordNotesHook.activate()"
|
||||||
},
|
},
|
||||||
p.replacement
|
p.replacement
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue