Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions frontend/src/includes/ManageSidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,39 @@
guild = res.data;
}

function checkGuildCache(id, newIcon, newName) {
// Retrieve the guilds array from localStorage
let guilds = JSON.parse(window.localStorage.getItem('guilds')) || [];

// Find the guild with the specified id
let guild = guilds.find(g => g.id === id);

// If the guild is found, update its icon and name
if (guild) {
let updated = false;
if (guild.icon !== newIcon) {
guild.icon = newIcon;
updated = true;
}
if (guild.name !== newName) {
guild.name = newName;
updated = true;
}
// Save the updated guilds array back to localStorage if there were changes
if (updated) {
window.localStorage.setItem('guilds', JSON.stringify(guilds));
}
} else {
console.error(`Guild with id ${id} not found`);
}
}

onMount(async () => {
await withLoadingScreen(async () => {
await loadGuild();

iconUrl = getIconUrl(guildId, guild.icon);
checkGuildCache(guildId, guild.icon, guild.name);
})
});
</script>