Skip to content

Commit

Permalink
fix issues related to account merging
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgi-o committed Mar 31, 2023
1 parent 24c2afc commit 9d149b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 3 additions & 4 deletions discord/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ export const renderOffers = async (shop, interaction, valorantUser, VPemoji, oth
// show notice if there is one
if(config.notice) {
// users shouldn't see the same notice twice
const user = getUser(interaction.user.id);
if(user.lastNoticeSeen !== config.notice) {
if(valorantUser.lastNoticeSeen !== config.notice) {

// the notice can either be just a simple string, or a raw JSON embed data object
if(typeof config.notice === "string") {
Expand All @@ -136,8 +135,8 @@ export const renderOffers = async (shop, interaction, valorantUser, VPemoji, oth
}
else embeds.push(EmbedBuilder.from(config.notice).toJSON());

user.lastNoticeSeen = config.notice;
saveUser(user);
valorantUser.lastNoticeSeen = config.notice;
saveUser(valorantUser);
}
}

Expand Down
11 changes: 10 additions & 1 deletion valorant/accountSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,18 @@ export const addUser = (user) => {
let foundDuplicate = false;
for(let i = 0; i < userJson.accounts.length; i++) {
if(userJson.accounts[i].puuid === user.puuid) {
user.alerts = removeDupeAlerts(user.alerts.concat(userJson.accounts[i].alerts));
const oldUser = userJson.accounts[i];

// merge the accounts
userJson.accounts[i] = user;
userJson.currentAccount = i + 1;

// copy over data from old account
user.alerts = removeDupeAlerts(user.alerts.concat(userJson.accounts[i].alerts));
user.lastFetchedData = oldUser.lastFetchedData;
user.lastNoticeSeen = oldUser.lastNoticeSeen;
user.lastSawEasterEgg = oldUser.lastSawEasterEgg;

foundDuplicate = true;
}
}
Expand Down

0 comments on commit 9d149b1

Please sign in to comment.