Fix misc plugins errors on account switch
This commit is contained in:
parent
ce0740b885
commit
152d4fdbb3
2 changed files with 8 additions and 7 deletions
|
@ -50,6 +50,8 @@ async function runMigrations() {
|
||||||
|
|
||||||
export async function syncAndRunChecks() {
|
export async function syncAndRunChecks() {
|
||||||
await runMigrations();
|
await runMigrations();
|
||||||
|
if (UserStore.getCurrentUser() == null) return;
|
||||||
|
|
||||||
const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
|
const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
|
||||||
guildsKey(),
|
guildsKey(),
|
||||||
groupsKey(),
|
groupsKey(),
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { getIntlMessage } from "@utils/discord";
|
import { getIntlMessage } from "@utils/discord";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findComponentByCodeLazy, findExportedComponentLazy, findStoreLazy } from "@webpack";
|
import { findComponentByCodeLazy, findExportedComponentLazy, findStoreLazy } from "@webpack";
|
||||||
import { ChannelStore, GuildMemberStore, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
import { GuildMemberStore, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
import { buildSeveralUsers } from "../typingTweaks";
|
import { buildSeveralUsers } from "../typingTweaks";
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ function getDisplayName(guildId: string, userId: string) {
|
||||||
return GuildMemberStore.getNick(guildId, userId) ?? (user as any).globalName ?? user.username;
|
return GuildMemberStore.getNick(guildId, userId) ?? (user as any).globalName ?? user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TypingIndicator({ channelId }: { channelId: string; }) {
|
function TypingIndicator({ channelId, guildId }: { channelId: string; guildId: string; }) {
|
||||||
const typingUsers: Record<string, number> = useStateFromStores(
|
const typingUsers: Record<string, number> = useStateFromStores(
|
||||||
[TypingStore],
|
[TypingStore],
|
||||||
() => ({ ...TypingStore.getTypingUsers(channelId) as Record<string, number> }),
|
() => ({ ...TypingStore.getTypingUsers(channelId) as Record<string, number> }),
|
||||||
|
@ -57,7 +57,6 @@ function TypingIndicator({ channelId }: { channelId: string; }) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const currentChannelId: string = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId());
|
const currentChannelId: string = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId());
|
||||||
const guildId = ChannelStore.getChannel(channelId).guild_id;
|
|
||||||
|
|
||||||
if (!settings.store.includeMutedChannels) {
|
if (!settings.store.includeMutedChannels) {
|
||||||
const isChannelMuted = UserGuildSettingsStore.isChannelMuted(guildId, channelId);
|
const isChannelMuted = UserGuildSettingsStore.isChannelMuted(guildId, channelId);
|
||||||
|
@ -165,7 +164,7 @@ export default definePlugin({
|
||||||
find: "UNREAD_IMPORTANT:",
|
find: "UNREAD_IMPORTANT:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
|
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
|
||||||
replace: "$&,$self.TypingIndicator($1.id)"
|
replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Theads
|
// Theads
|
||||||
|
@ -174,14 +173,14 @@ export default definePlugin({
|
||||||
find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z",
|
find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /mentionsCount:\i.+?null(?<=channel:(\i).+?)/,
|
match: /mentionsCount:\i.+?null(?<=channel:(\i).+?)/,
|
||||||
replace: "$&,$self.TypingIndicator($1.id)"
|
replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
TypingIndicator: (channelId: string) => (
|
TypingIndicator: (channelId: string, guildId: string) => (
|
||||||
<ErrorBoundary noop>
|
<ErrorBoundary noop>
|
||||||
<TypingIndicator channelId={channelId} />
|
<TypingIndicator channelId={channelId} guildId={guildId} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue