Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLA-2011] collections hotsync #162

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion resources/js/api/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ export class CollectionApi {
return ApiService.sendPlatformRequest(data);
}

static async trackCollection(collectionId: string) {
static async trackCollection(collectionId: string, hotSync: boolean = false) {
const data = {
query: mutations.TrackCollection,
variables: {
chainIds: [parseInt(collectionId)],
hotSync,
},
};

Expand Down
11 changes: 7 additions & 4 deletions resources/js/components/TrackCollectionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<div class="flex justify-end space-x-4 mt-6">
<Btn dusk="trackCancelBtn" @click="closeModal">Cancel</Btn>
<Btn dusk="trackConfirmBtn" primary @click="confirm">Track</Btn>
<Btn dusk="trackConfirmBtn" primary :loading="loading" :disabled="loading" @click="confirm">Track</Btn>
</div>
</Modal>
</template>
Expand All @@ -31,24 +31,27 @@ import { DialogTitle } from '@headlessui/vue';
import Btn from '~/components/Btn.vue';
import Modal from '~/components/Modal.vue';
import FormInput from './FormInput.vue';
import { onUnmounted, ref } from 'vue';
import { onMounted, ref } from 'vue';

const props = defineProps<{ isOpen: boolean }>();

const emit = defineEmits(['closed', 'confirm']);

const collectionId = ref();
const loading = ref(false);

const confirm = async () => {
loading.value = true;
emit('confirm', collectionId.value);
closeModal();
};

const closeModal = () => {
collectionId.value = '';
emit('closed');
};

onUnmounted(() => {
onMounted(() => {
collectionId.value = '';
loading.value = false;
});
</script>
7 changes: 5 additions & 2 deletions resources/js/components/pages/Collections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,21 @@ const openTransactionSlide = async (transactionId: string) => {

const trackCollection = async (collectionId: string) => {
try {
await CollectionApi.trackCollection(collectionId);
const hotSync = !appStore.isMultiTenant;
await CollectionApi.trackCollection(collectionId, hotSync);
await getCollections();
snackbar.success({
title: 'Tracking',
text: 'Collection tracked successfully',
save: false,
});
} catch {
snackbar.info({
snackbar.error({
title: 'Tracking',
text: 'Tracking the collection failed',
});
} finally {
trackModal.value = false;
}
};

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! = COLLECTION, $chainIds:[BigInt!]!) {
AddToTracked(type: $type, chainIds: $chainIds, hotSync: false)
export default `mutation addToTracked($type: ModelType! = COLLECTION, $chainIds:[BigInt!]!, $hotSync: Boolean = false) {
AddToTracked(type: $type, chainIds: $chainIds, hotSync: $hotSync)
}`;
Loading