Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/improsocial/impro
An extensible Bluesky client for web impro.social
Something went wrong. Try again.
JavaScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112import { hapticsImpactMedium } from "/js/haptics.js";import { showToast } from "/js/toasts.js";import { confirmModal } from "/js/modals/confirm.modal.js";
export class ListInteractionHandler { constructor(dataLayer) { this.dataLayer = dataLayer; }
async handlePinList(listUri, doPin) { if (doPin) { try { hapticsImpactMedium(); await this.dataLayer.mutations.pinList(listUri); showToast("List pinned"); } catch (error) { console.error(error); showToast("Failed to pin list", { style: "error" }); } } else { try { await this.dataLayer.mutations.unpinList(listUri); showToast("List unpinned"); } catch (error) { console.error(error); showToast("Failed to unpin list", { style: "error" }); } } }
async handleMuteList(list) { const confirmed = await confirmModal( "The users on this list will be muted for you. Their posts won't appear in your feeds. Muting is private.", { title: "Mute these accounts?", confirmButtonText: "Mute", }, ); if (!confirmed) return; try { hapticsImpactMedium(); await this.dataLayer.mutations.muteModList(list); showToast("List muted"); } catch (error) { console.error(error); showToast("Failed to mute list", { style: "error" }); } }
async handleUnmuteList(list) { try { await this.dataLayer.mutations.unmuteModList(list); showToast("List unmuted"); } catch (error) { console.error(error); showToast("Failed to unmute list", { style: "error" }); } }
async handleBlockList(list) { const confirmed = await confirmModal( "The users on this list will be blocked. They won't be able to interact with you, and you won't see their content. Blocking is public.", { title: "Block these accounts?", confirmButtonText: "Block", confirmButtonStyle: "danger", }, ); if (!confirmed) return; try { hapticsImpactMedium(); await this.dataLayer.mutations.blockModList(list); showToast("List blocked"); } catch (error) { console.error(error); showToast("Failed to block list", { style: "error" }); } }
async handleUnblockList(list) { try { await this.dataLayer.mutations.unblockModList(list); showToast("List unblocked"); } catch (error) { console.error(error); showToast("Failed to unblock list", { style: "error" }); } }
async handleDeleteList(list) { return await confirmModal( "This list will be permanently deleted. This action cannot be undone.", { title: "Delete this list?", confirmButtonText: "Delete", pendingText: "Deleting…", confirmButtonStyle: "danger", onConfirm: async () => { try { await this.dataLayer.mutations.deleteList(list); showToast("List deleted"); } catch (error) { console.error(error); showToast("Failed to delete list", { style: "error" }); throw error; } }, }, ); }}