Refactor this. Make it simpler and prettier: [code]
- User
Refactor this. Make it simpler and prettier:
switch (string) { case 'Залогинился с UA': return { type: 'login' }; case 'Установка метки на посте': return { type: 'mark_post' }; case 'Добавлен мод тег': return { type: 'mod_mark' }; case 'Изменён FAQ': return { type: 'faq_edit' }; case 'Добавлен модер': return { type: 'moder_add' }; case 'Отредактирован модер': return { type: 'moder_edit' }; case 'Пароль модератора сброшен': return { type: 'moder_reset' }; case 'Забанен пасскод': return { type: 'passcode_ban' }; case 'Разбанен пасскод': return { type: 'passcode_unban' }; case 'Разрешение запроса на бан': return { type: 'banrequest_allow' }; case 'Удаление запроса на бан': return { type: 'banrequest_disallow' }; case 'Добавление запроса на бан': return { type: 'banrequest_add' }; case 'Прикреплён тред': return { type: 'thread_pin' }; case 'Откреплён тред': return { type: 'thread_unpin' }; case 'Открыт тред': return { type: 'thread_open' }; case 'Закрыт тред': return { type: 'thread_close' }; case 'Включён бесконечный тред': return { type: 'thread_enable_endless' }; case 'Отключён бесконечный тред': return { type: 'thread_disable_endless' }; case 'Спамлист обновлён': return { type: 'spamlist_update' }; case 'Добавлено антивайп правило': return { type: 'antiwipe_rule_add' }; case 'Удалено антивайп правило': return { type: 'antiwipe_rule_remove' }; case 'Обновлен черный список стран': return { type: 'antiwipe_blacklist_update' }; case 'Обновлен белый список стран': return { type: 'antiwipe_whitelist_update' }; case 'Добавлена автозамена': return { type: 'autoreplace_add' }; case 'Удалена автозамена': return { type: 'autoreplace_remove' }; case 'Добавление в таблицу банов': return { type: 'ban_add' }; case 'Включён бан': return { type: 'ban_toggle' }; case 'Удаление из таблицы \'comments_\'': return { type: 'board_post_remove', board: string.match(/'comments_(.*)'/)[1] }; case 'Удаление бамплимита из таблицы \'comments_\'': return { type: 'board_bumplimit_remove', board: string.match(/'comments_(.*)'/)[1] }; case 'Удаление файла из таблицы \'comments_\'': return { type: 'board_file_remove', board: string.match(/'comments_(.*)'/)[1] }; case 'Удалена жалоба': return { type: 'report_remove' }; case 'Изменены причины банов': return { type: 'reasons_update' }; case 'Удалён рекрут': return { type: 'recruit_remove' }; } - Assistant
- User
Can you rewrite it that the object in actionMap should not be the exact string, like if i write "Установка метки", it will find object in actionMap that includes this string, even though this is not the exact string
- Assistant
- User
Inst the matching thing is boilerplate? Can it be easier
- Assistant