Repository: louislam/uptime-kuma
File: src/components/MonitorList.vue (Vue)

Code before:
            }
            this.cancelSelectMode();
        },
        /**
         * Show dialog to confirm deletion
         * @returns {void}
         */
        deleteDialog() {
            this.$refs.confirmDelete.show();
        },
        /**
         * Delete each selected monitor
         * @returns {void}
         */
        deleteSelected() {
            const count = Object.keys(this.selectedMonitors).length;
            let successCount = 0;
            let errorCount = 0;

            Object.keys(this.selectedMonitors).forEach((id) => {
                this.$root.getSocket().emit("deleteMonitor", id, false, (res) => {
                    if (res.ok) {
                        successCount++;
                    } else {
                        errorCount++;
                        this.$root.toastError(res.msg);
                    }

                    // Show succes message after all deletions completed
                    if (successCount + errorCount === count && successCount > 0) {
                        this.$root.toastSuccess(this.$t("deletedMonitorsMsg", [successCount]));
                    }
                });
            });

            this.cancelSelectMode();
        },
        /**
         * Whether a monitor should be displayed based on the filters
         * @param {object} monitor Monitor to check
         * @returns {boolean} Should the monitor be displayed
         */
        filterFunc(monitor) {
            // Group monitors bypass filter if at least 1 of children matched
            if (monitor.type === "group") {
                const children = Object.values(this.$root.monitorList).filter((m) => m.parent === monitor.id);
                if (children.some((child, index, children) => this.filterFunc(child))) {
                    return true;
                }
            }


Review comment (suggestion):
this could show a potentially very long walls of erros.
I think it would be better if we would convert this to an async function and handle the errors only once instead of every time.

Code after:
            activeMonitors.forEach((id) => this.$root.getSocket().emit("pauseMonitor", id, () => {}));
            this.$root.toastSuccess(this.$tc("pausedMonitorsMsg", activeMonitors.length));
            this.bulkActionInProgress = false;
            this.cancelSelectMode();
        },
        /**
         * Resume each selected monitor
         * @returns {void}
         */
        resumeSelected() {
            if (this.bulkActionInProgress) {
                return;
            }

            const inactiveMonitors = Object.keys(this.selectedMonitors).filter(
                (id) => !this.$root.monitorList[id].active
            );

            if (inactiveMonitors.length === 0) {
                this.$root.toastError(this.$t("noMonitorsResumedMsg"));
                return;
            }

            this.bulkActionInProgress = true;
            inactiveMonitors.forEach((id) => this.$root.getSocket().emit("resumeMonitor", id, () => {}));
            this.$root.toastSuccess(this.$tc("resumedMonitorsMsg", inactiveMonitors.length));
            this.bulkActionInProgress = false;
            this.cancelSelectMode();
        },
        /**
         * Delete each selected monitor
         * @returns {Promise<void>}
         */
        async deleteSelected() {
            if (this.bulkActionInProgress) {
                return;
            }

            const monitorIds = Object.keys(this.selectedMonitors);

            this.bulkActionInProgress = true;
            let successCount = 0;
            let errorCount = 0;

            for (const id of monitorIds) {
                try {
                    await new Promise((resolve, reject) => {
                        this.$root.getSocket().emit("deleteMonitor", id, false, (res) => {
                            if (res.ok) {
                                successCount++;
                                resolve();