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

Code before:
        isSelected(id) {
            return id in this.selectedMonitors;
        },
        /**
         * Disable select mode and reset selection
         * @returns {void}
         */
        cancelSelectMode() {
            this.selectMode = false;
            this.selectedMonitors = {};
        },
        /**
         * Show dialog to confirm pause
         * @returns {void}
         */
        pauseDialog() {
            this.$refs.confirmPause.show();
        },
        /**
         * Pause each selected monitor
         * @returns {void}
         */
        pauseSelected() {
            const count = Object.keys(this.selectedMonitors).filter((id) => this.$root.monitorList[id].active).length;
            Object.keys(this.selectedMonitors)
                .filter((id) => this.$root.monitorList[id].active)
                .forEach((id) => this.$root.getSocket().emit("pauseMonitor", id, () => {}));

            if (count > 0) {
                this.$root.toastSuccess(this.$t("pausedMonitorsMsg", [count]));
            }
            this.cancelSelectMode();
        },
        /**
         * Resume each selected monitor
         * @returns {void}
         */
        resumeSelected() {
            const count = Object.keys(this.selectedMonitors).filter((id) => !this.$root.monitorList[id].active).length;
            Object.keys(this.selectedMonitors)
                .filter((id) => !this.$root.monitorList[id].active)
                .forEach((id) => this.$root.getSocket().emit("resumeMonitor", id, () => {}));

            if (count > 0) {
                this.$root.toastSuccess(this.$t("resumedMonitorsMsg", [count]));
            }
            this.cancelSelectMode();
        },
        /**
         * Show dialog to confirm deletion
         * @returns {void}

Review comment (refactor):
Please extract this code in cases like this instead of duplicating it.
Much simpler to read this way

This suggestion also affects the code below in this function and the resume/delete function

```suggestion
            const activeMonitors = Object.keys(this.selectedMonitors).filter((id) => this.$root.monitorList[id].active);
           activeMonitors
```

Code after:
         * @returns {void}
         */
        select(id) {
            this.selectedMonitors[id] = true;
        },
        /**
         * Determine if monitor is selected
         * @param {number} id ID of monitor
         * @returns {bool} Is the monitor selected?
         */
        isSelected(id) {
            return id in this.selectedMonitors;
        },
        /**
         * Disable select mode and reset selection
         * @returns {void}
         */
        cancelSelectMode() {
            this.selectMode = false;
            this.selectedMonitors = {};
        },
        /**
         * Show dialog to confirm pause
         * @returns {void}
         */
        pauseDialog() {
            this.$refs.confirmPause.show();
        },
        /**
         * Pause each selected monitor
         * @returns {void}
         */
        pauseSelected() {
            if (this.bulkActionInProgress) {
                return;
            }

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

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

            this.bulkActionInProgress = true;
            activeMonitors.forEach((id) => this.$root.getSocket().emit("pauseMonitor", id, () => {}));
            this.$root.toastSuccess(this.$tc("pausedMonitorsMsg", activeMonitors.length));
            this.bulkActionInProgress = false;
            this.cancelSelectMode();
        },
        /**