Skip to content

Commit

Permalink
reload tokens and nfts when switching safes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Feb 22, 2024
1 parent a9a002e commit ab9f1e5
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/plugins/oSnap/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ const update = (newPluginData: OsnapPluginData) => {
emit('update', { key: 'oSnap', form: newPluginData });
};
watch(newPluginData, async () => {
async function loadBalancesAndCollectibles() {
if (!newPluginData.value.safe?.safeAddress) return;
isLoading.value = true;
tokens.value = await fetchBalances(
newPluginData.value.safe.network,
newPluginData.value.safe.safeAddress
Expand All @@ -209,20 +210,26 @@ watch(newPluginData, async () => {
newPluginData.value.safe.network,
newPluginData.value.safe.safeAddress
);
});
isLoading.value = false;
}
watch(
() => [
newPluginData.value.safe?.safeAddress,
newPluginData.value.safe?.network
],
async () => {
await loadBalancesAndCollectibles();
update(newPluginData.value);
}
);
onMounted(async () => {
isLoading.value = true;
safes.value = await createOsnapEnabledSafes();
newPluginData.value.safe = cloneDeep(safes.value[0]);
tokens.value = await fetchBalances(
newPluginData.value.safe.network,
newPluginData.value.safe.safeAddress
);
collectables.value = await fetchCollectibles(
newPluginData.value.safe.network,
newPluginData.value.safe.safeAddress
);
await loadBalancesAndCollectibles();
update(newPluginData.value);
isLoading.value = false;
});
Expand Down

0 comments on commit ab9f1e5

Please sign in to comment.