Skip to content

Commit

Permalink
Reload my nfts on key change
Browse files Browse the repository at this point in the history
  • Loading branch information
greimela committed Jul 22, 2022
1 parent 26a0d41 commit 4b31ca2
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/pages/MyNfts.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
<script setup lang="ts">
import { ViewGridIcon, SparklesIcon } from '@heroicons/vue/outline';
import { IpcService } from '../helpers/ipc-service';
import { ref } from 'vue';
import { ref, watch } from 'vue';
import { openNftOnMintGarden } from '../helpers/open-external';
import { chiaState } from '../state/chia';
const ipc = new IpcService();
const nfts = ref([]);
const nfts = ref<any[]>([]);
const getNfts = async () => {
const { dids } = await ipc.send<any>('get_dids');
nfts.value = [];
const myNfts = [];
for (const did of dids) {
const { nfts: newNfts } = await ipc.send<any>('get_nfts_for_did', { did: did.didId });
if (newNfts) {
nfts.value = [...nfts.value, ...newNfts];
myNfts.push(...newNfts);
}
console.log(newNfts);
}
nfts.value = myNfts;
};
getNfts();
watch(
() => ({ ...chiaState }),
(value, oldValue) => {
if (oldValue.activeFingerprint !== value.activeFingerprint) {
getNfts();
}
if (!oldValue.synced && value.synced) {
getNfts();
}
}
);
</script>
<template>
<div class="p-8 w-full xl:max-w-7xl space-y-8">
Expand Down

0 comments on commit 4b31ca2

Please sign in to comment.