UI: Slow mode tweaks. (#11081)

UI: Slow mode tweaks. (#11081)

We remove the slow mode composer message and provide better messages when rejecting new posts and edits. The client now validates if the user tries to post again immediately. Finally, we replaced the hourglass-end icon with the hourglass-start one.

diff --git a/app/assets/javascripts/discourse/app/components/composer-messages.js b/app/assets/javascripts/discourse/app/components/composer-messages.js
index e3fbca1..3273da6 100644
--- a/app/assets/javascripts/discourse/app/components/composer-messages.js
+++ b/app/assets/javascripts/discourse/app/components/composer-messages.js
@@ -4,7 +4,6 @@ import EmberObject from "@ember/object";
 import { scheduleOnce } from "@ember/runloop";
 import Component from "@ember/component";
 import LinkLookup from "discourse/lib/link-lookup";
-import { durationTextFromSeconds } from "discourse/helpers/slow-mode";
 
 let _messagesCache = {};
 
@@ -117,21 +116,6 @@ export default Component.extend({
       }
     }
 
-    const topic = composer.topic;
-    if (topic && topic.slow_mode_seconds) {
-      const msg = composer.store.createRecord("composer-message", {
-        id: "slow-mode-enabled",
-        extraClass: "custom-body",
-        templateName: "custom-body",
-        title: I18n.t("composer.slow_mode.title"),
-        body: I18n.t("composer.slow_mode.body", {
-          duration: durationTextFromSeconds(topic.slow_mode_seconds),
-        }),
-      });
-
-      this.send("popup", msg);
-    }
-
     this.queuedForTyping.forEach((msg) => this.send("popup", msg));
   },
 
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 488a975..cb24c87 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -28,7 +28,10 @@ import { isTesting } from "discourse-common/config/environment";
 import EmberObject, { computed, action } from "@ember/object";
 import deprecated from "discourse-common/lib/deprecated";
 import bootbox from "bootbox";
-import { cannotPostAgain } from "discourse/helpers/slow-mode";
+import {
+  cannotPostAgain,
+  durationTextFromSeconds,
+} from "discourse/helpers/slow-mode";
 
 function loadDraft(store, opts) {
   let promise = Promise.resolve();
@@ -661,10 +664,15 @@ export default Controller.extend({
           topic.user_last_posted_at
         )
       ) {
-        const message = I18n.t("composer.slow_mode.error");
+        const message = I18n.t("composer.slow_mode.error", {
+          duration: durationTextFromSeconds(topic.slow_mode_seconds),
+        });
 
         bootbox.alert(message);
         return;
+      } else {
+        // Edge case where the user tries to post again immediately.
+        topic.set("user_last_posted_at", new Date().toISOString());
       }
     }
 
diff --git a/app/assets/javascripts/discourse/app/templates/components/slow-mode-info.hbs b/app/assets/javascripts/discourse/app/templates/components/slow-mode-info.hbs
index c393ee7..21ae5a3 100644
--- a/app/assets/javascripts/discourse/app/templates/components/slow-mode-info.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/slow-mode-info.hbs
@@ -2,7 +2,7 @@
   <div class="topic-status-info">
     <h3 class="slow-mode-heading">
       <span>
-        {{d-icon "hourglass-end"}}
+        {{d-icon "hourglass-start"}}
         {{i18n "topic.slow_mode_notice.duration" duration=durationText}}
       </span>
 
diff --git a/app/assets/javascripts/discourse/app/templates/modal/edit-slow-mode.hbs b/app/assets/javascripts/discourse/app/templates/modal/edit-slow-mode.hbs
index 29cd5fc..956db77 100644
--- a/app/assets/javascripts/discourse/app/templates/modal/edit-slow-mode.hbs
+++ b/app/assets/javascripts/discourse/app/templates/modal/edit-slow-mode.hbs
@@ -30,6 +30,7 @@
 <div class="modal-footer">
   {{d-button class="btn-primary"
       disabled=submitDisabled
+      icon="hourglass-start"
       label="topic.slow_mode_update.save"
       action=(action "enableSlowMode")}}
 
diff --git a/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js b/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js
index 6d9447e..f5e1eb5 100644
--- a/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js
@@ -274,7 +274,7 @@ export default createWidget("topic-admin-menu", {
         className: "topic-admin-slow-mode",
         buttonClass: "popup-menu-btn",
         action: "showTopicSlowModeUpdate",
-        icon: "hourglass-end",
+        icon: "hourglass-start",
         label: "actions.slow_mode",
       });
 
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 061fe1e..d257c71 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1925,9 +1925,7 @@ en:
         title: "Did you forget to add recipients?"
         body: "Right now this message is only being sent to yourself!"
       slow_mode:
-        title: "This topic is in slow mode."
-        body: "After submitting a post, you'll need to wait %{duration} before being able to post again."
-        error: "You recently posted on this topic, which is in slow mode. Please wait so other users can have their chance to participate."
+        error: "This topic is in slow mode. In order to promote thoughtful, considered discussion you may only post once every %{duration}."
 
       admin_options_title: "Optional staff settings for this topic"
 
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 608a288..4c2c6fe 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -384,7 +384,7 @@ en:
   too_late_to_edit: "That post was created too long ago. It can no longer be edited or deleted."
   edit_conflict: "That post was edited by another user and your changes can no longer be saved."
   revert_version_same: "The current version is same as the version you are trying to revert to."
-  cannot_edit_on_slow_mode: "The topic is in slow mode and that post can no longer be edited."
+  cannot_edit_on_slow_mode: "This topic is in slow mode. To encourage thoughtful, considered discussion, editing old posts is not currently allowed."
 
   excerpt_image: "image"
 
diff --git a/lib/svg_sprite/svg_sprite.rb b/lib/svg_sprite/svg_sprite.rb
index ffa83a3..364e70a 100644
--- a/lib/svg_sprite/svg_sprite.rb
+++ b/lib/svg_sprite/svg_sprite.rb
@@ -130,7 +130,7 @@ module SvgSprite
     "heading",
     "heart",
     "home",
-    "hourglass-end",
+    "hourglass-start",
     "id-card",
     "info-circle",
     "italic",

GitHub sha: 7912ce40

This commit appears in #11081 which was approved by pmusaraj. It was merged by romanrizzi.