Skip to content

Commit

Permalink
Stop crashes (mod doesn't fully initialize yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
colin273 committed Jul 4, 2024
1 parent 40eb0a4 commit 1173064
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/renderer/coremods/language/plaintextPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ export default [
replacements: [
{
match: /(\.Messages\.LANGUAGE,)\s*children:((?:[^}]*?}){3}\))/,
replace: (_, prefix, ogChild) => `${prefix}children:[${coremodStr}.Card(),${ogChild}]`,
replace: (_, prefix, ogChild) =>
`${prefix}children:[${coremodStr}?.Card() ?? null,${ogChild}]`,
},
{
match: /children:\[(.+?\.localeName[^\]]*?)]/,
replace: (_, ogChild) => `children:[${coremodStr}.Percentage(${ogChild})]`,
replace: (_, ogChild) => `children:[${coremodStr}?.Percentage(${ogChild}) ?? ${ogChild}]`,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/coremods/messagePopover/plaintextPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default [
match:
/(Fragment,{children:\[)(.{0,200}children:\[.{0,20}?(\w{1,3})\({.{0,5}\s?key:"copy-id".{0,20}channel:(.{1,3})[,}].{0,20}message:(.{1,3})[,}])/,
replace: (_, prefix, suffix, makeButton, channel, message) =>
`${prefix}...replugged.coremods.coremods.messagePopover._buildPopoverElements(${message},${channel},${makeButton}),${suffix}`,
`${prefix}...(replugged.coremods.coremods.messagePopover?._buildPopoverElements(${message},${channel},${makeButton}) ?? []),${suffix}`,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/coremods/notices/plaintextPatches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default [
{
match: /(\w+\.base,children:\[)(.+?}\)),/,
replace: (_, prefix, noticeWrapper) =>
`${prefix}${coremodStr}.AnnouncementContainer({originalRes:${noticeWrapper}}),`,
`${prefix}${coremodStr}?.AnnouncementContainer({originalRes:${noticeWrapper}}) ?? ${noticeWrapper},`,
},
],
},
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/coremods/settings/plaintextPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default [
find: "getPredicateSections",
replacements: [
{
match: /this\.props\.sections\.filter\((.+?)\)}/,
replace: (_, sections) =>
`${coremodStr}.insertSections(this.props.sections.filter(${sections}))};`,
match: /(this\.props\.sections\.filter\(.+?\))}/,
replace: (_, filteredSections) =>
`${coremodStr}?.insertSections(${filteredSections}) ?? ${filteredSections}};`,
},
],
},
Expand All @@ -18,7 +18,7 @@ export default [
replacements: [
{
match: /appArch,children:.{0,200}?className:\w+\.line,.{0,100}children:\w+}\):null/,
replace: `$&,${coremodStr}.VersionInfo()`,
replace: `$&,${coremodStr}?.VersionInfo() ?? null`,
},
],
},
Expand Down

0 comments on commit 1173064

Please sign in to comment.