CallTimer: fix mappings
This commit is contained in:
parent
bcf87fa382
commit
9e2a1b97f9
1 changed files with 3 additions and 8 deletions
|
|
@ -71,7 +71,7 @@ export const settings = definePluginSettings({
|
|||
});
|
||||
|
||||
// Save the join time of all users in a Map
|
||||
type userJoinData = { channelId: string, time: number; guildId: string; };
|
||||
type userJoinData = { channelId: string, time: number; guildId: string | null; };
|
||||
const userJoinTimes = new Map<string, userJoinData>();
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +84,7 @@ const userJoinTimes = new Map<string, userJoinData>();
|
|||
* unique identifier of the guild (server) to which the user belongs. It is used to associate the
|
||||
* user's join time with a specific guild within the application or platform.
|
||||
*/
|
||||
function addUserJoinTime(userId: string, channelId: string, guildId: string) {
|
||||
function addUserJoinTime(userId: string, channelId: string, guildId: string | null) {
|
||||
// create a random number
|
||||
userJoinTimes.set(userId, { channelId, time: Date.now(), guildId });
|
||||
}
|
||||
|
|
@ -152,11 +152,6 @@ export default definePlugin({
|
|||
const { userId, channelId, guildId } = state;
|
||||
const isMe = userId === myId;
|
||||
|
||||
if (!guildId) {
|
||||
// guildId is never undefined here
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if the state does not actually has a `oldChannelId` property
|
||||
if (!("oldChannelId" in state) && !runOneTime && !settings.store.watchLargeGuilds) {
|
||||
// batch update triggered. This is ignored because it
|
||||
|
|
@ -173,7 +168,7 @@ export default definePlugin({
|
|||
if (channelId !== oldChannelId) {
|
||||
if (channelId) {
|
||||
// move or join
|
||||
addUserJoinTime(userId, channelId, guildId);
|
||||
addUserJoinTime(userId, channelId, guildId ?? null);
|
||||
} else if (oldChannelId) {
|
||||
// leave
|
||||
removeUserJoinTime(userId);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue