Skip to content

Commit

Permalink
add tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
zlayine committed Jul 26, 2024
1 parent 744f8cc commit 4c9f1ae
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions resources/js/api/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class CollectionApi {
const data = {
query: mutations.TrackCollection,
variables: {
collectionId,
chainIds: [parseInt(collectionId)],
},
};

Expand All @@ -173,7 +173,7 @@ export class CollectionApi {
const data = {
query: mutations.UntrackCollection,
variables: {
collectionId,
chainIds: [parseInt(collectionId)],
},
};

Expand Down
12 changes: 10 additions & 2 deletions resources/js/components/pages/Collections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
</div>
</div>
<div class="flex space-x-4 md:px-6 lg:px-8 py-2 mb-2 items-end">
<Btn dusk="trackCollectionBtn" primary @click="trackModal = true">Track</Btn>
<Btn
v-if="useAppStore().isMultiTenant"
dusk="trackCollectionBtn"
primary
@click="trackModal = true"
>
Track
</Btn>
<RouterLink :to="{ name: 'platform.create.collection' }">
<Btn dusk="createCollectionBtn" primary> Create Collection </Btn>
</RouterLink>
Expand Down Expand Up @@ -123,7 +130,7 @@
class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-3 flex justify-end"
>
<DropdownMenu
v-if="collection.tracked"
v-if="!collection.tracked"
:actions="actions"
@clicked="($event) => openModalSlide($event, collection)"
/>
Expand Down Expand Up @@ -181,6 +188,7 @@ const collections: Ref<{
totalCount: number;
};
frozen: boolean;
tracked?: boolean;
}[];
cursor: string | null;
}> = ref({
Expand Down
8 changes: 8 additions & 0 deletions resources/js/factory/collection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { useAppStore } from '~/store';
import { FreezeType } from '~/types/types.enums';
import { publicKeyToAddress } from '~/util/address';

export class DTOCollectionFactory {
public static buildCollection(collection: any): any {
const accounts: string[] = useAppStore().user?.walletAccounts ?? [];
let tracked = false;
if (accounts.length && useAppStore().isMultiTenant) {
tracked = !accounts.some((account) => account === collection.owner.account.publicKey);
}

return {
...collection,
royalty: {
Expand All @@ -11,6 +18,7 @@ export class DTOCollectionFactory {
},
owner: publicKeyToAddress(collection.owner.account.publicKey),
freezeType: FreezeType.COLLECTION,
tracked,
};
}

Expand Down
4 changes: 2 additions & 2 deletions resources/js/graphql/mutation/TrackCollection.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default `mutation addToTracked($type: ModelType!, $chainIds:[BigInt!]!) {
AddToTracked(type:$type, chainIds:$chainIds, hotSync:false)
export default `mutation addToTracked($type: ModelType! = COLLECTION, $chainIds:[BigInt!]!) {
AddToTracked(type: $type, chainIds: $chainIds, hotSync: false)
}`;
4 changes: 2 additions & 2 deletions resources/js/graphql/mutation/UntrackCollection.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default `mutation removeFromTracked($type: ModelType!, $chainIds: [BigInt!]!) {
RemoveFromTracked(type:$type, chainIds:$chainIds)
export default `mutation removeFromTracked($type: ModelType! = COLLECTION, $chainIds: [BigInt!]!) {
RemoveFromTracked(type: $type, chainIds: $chainIds)
}`;
4 changes: 3 additions & 1 deletion resources/js/store/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export const useConnectionStore = defineStore('connection', {
return;
}
await this.getAccounts();
AuthApi.setUserAccounts(this.accounts.map((account) => publicKeyToAddress(account.address)));
if (useAppStore().isMultiTenant) {
AuthApi.setUserAccounts(this.accounts.map((account) => publicKeyToAddress(account.address)));
}
}
},
async connectWallet(provider: string, endLoading: Function, notify = true) {
Expand Down

0 comments on commit 4c9f1ae

Please sign in to comment.