summaryrefslogblamecommitdiffstatshomepage
path: root/frontend/src/lib/toolbar/MarkBookmark.svelte
blob: 776ddd8dd3d294514ee9d6225f69b46cb1a1449b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                  
                                                       
                                                          


                                                                              



                                                
                                                                                         

                                              
                                                                                                    


         
                                                                                              


                                      
                                                                                               


                                       
<script lang="ts">
	import type { MutationWith } from '$gql/Utils';
	import Bookmark from '$lib/icons/Bookmark.svelte';
	import { getSelectionContext } from '$lib/selection/Selection.svelte';
	import { toastFinally } from '$lib/Toasts';
	import { getContextClient } from '@urql/svelte';

	const client = getContextClient();
	const selection = getSelectionContext();

	let { mutation }: { mutation: MutationWith<{ bookmarked: boolean }> } = $props();

	function mutate(bookmarked: boolean) {
		mutation(client, { ids: selection.ids, input: { bookmarked } }).catch(toastFinally);
	}
</script>

<button type="button" class="btn-slate flex justify-start gap-1" onclick={() => mutate(true)}>
	<Bookmark bookmarked={true} />
	<span>Bookmark</span>
</button>
<button type="button" class="btn-slate flex justify-start gap-1" onclick={() => mutate(false)}>
	<Bookmark bookmarked={false} />
	<span>Unbookmark</span>
</button>