diff --git a/app/assets/javascripts/discourse/controllers/static.js.es6 b/app/assets/javascripts/discourse/controllers/static.js.es6
index c22ce3c26d8..16b4d731e88 100644
--- a/app/assets/javascripts/discourse/controllers/static.js.es6
+++ b/app/assets/javascripts/discourse/controllers/static.js.es6
@@ -3,8 +3,11 @@ export default Ember.Controller.extend({
actions: {
markFaqRead() {
- if (this.currentUser) {
- Discourse.ajax("/users/read-faq", { method: "POST" });
+ const currentUser = this.currentUser;
+ if (currentUser) {
+ Discourse.ajax("/users/read-faq", { method: "POST" }).then(() => {
+ currentUser.set('read_faq', true);
+ });
}
}
}
diff --git a/app/assets/javascripts/discourse/templates/components/hamburger-menu.hbs b/app/assets/javascripts/discourse/templates/components/hamburger-menu.hbs
index 76289134c0a..8daa315a024 100644
--- a/app/assets/javascripts/discourse/templates/components/hamburger-menu.hbs
+++ b/app/assets/javascripts/discourse/templates/components/hamburger-menu.hbs
@@ -1,6 +1,17 @@
{{#menu-panel visible=visible}}
+ {{#unless currentUser.read_faq}}
+ {{#menu-links}}
+
+ {{#d-link path=faqUrl class="faq-link"}}
+ {{i18n "faq"}}
+ {{i18n "new_item"}}
+ {{/d-link}}
+
+ {{/menu-links}}
+ {{/unless}}
+
{{#if currentUser.staff}}
- {{#menu-links class="columned"}}
+ {{#menu-links}}
{{d-link route="admin" class="admin-link" icon="wrench" label="admin_title"}}
{{#d-link route="adminFlags" class="flagged-posts-link"}}
@@ -70,7 +81,9 @@
{{#menu-links omitRule="true"}}
{{d-link route="about" class="about-link" label="about.simple_title"}}
- {{d-link path=faqUrl class="faq-link" label="faq"}}
+ {{#if currentUser.read_faq}}
+ {{d-link path=faqUrl class="faq-link" label="faq"}}
+ {{/if}}
{{#if showKeyboardShortcuts}}
{{d-link action="keyboardShortcuts" class="keyboard-shortcuts-link" label="keyboard_shortcuts_help.title"}}
diff --git a/app/assets/javascripts/discourse/views/static.js.es6 b/app/assets/javascripts/discourse/views/static.js.es6
index 12dbfdf6036..35ce3d6749e 100644
--- a/app/assets/javascripts/discourse/views/static.js.es6
+++ b/app/assets/javascripts/discourse/views/static.js.es6
@@ -1,24 +1,28 @@
import isElementInViewport from "discourse/lib/is-element-in-viewport";
import ScrollTop from 'discourse/mixins/scroll-top';
-
-var readFaq = false;
+import { on } from 'ember-addons/ember-computed-decorators';
export default Ember.View.extend(ScrollTop, {
- _checkRead: function() {
- const path = this.get('controller.model.path');
- if (path === "faq" || path === "guidelines") {
- const controller = this.get('controller');
- $(window).on('load.faq resize.faq scroll.faq', function() {
- if (!readFaq && isElementInViewport($(".contents p").last())) {
- readFaq = true;
- controller.send('markFaqRead');
- }
- });
+ @on('didInsertElement')
+ _checkRead() {
+ const currentUser = this.get('controller.currentUser');
+ if (currentUser) {
+ const path = this.get('controller.model.path');
+ if (path === "faq" || path === "guidelines") {
+ const controller = this.get('controller');
+ $(window).on('load.faq resize.faq scroll.faq', function() {
+ const faqUnread = !currentUser.get('read_faq');
+ if (faqUnread && isElementInViewport($(".contents p").last())) {
+ controller.send('markFaqRead');
+ }
+ });
+ }
}
- }.on('didInsertElement'),
+ },
- _stopChecking: function(){
+ @on('willDestroyElement')
+ _stopChecking() {
$(window).off('load.faq resize.faq scroll.faq');
- }.on('willDestroyElement')
+ }
});
diff --git a/app/assets/stylesheets/common/base/menu-panel.scss b/app/assets/stylesheets/common/base/menu-panel.scss
index ce8219a4825..1e1c8cbb1ef 100644
--- a/app/assets/stylesheets/common/base/menu-panel.scss
+++ b/app/assets/stylesheets/common/base/menu-panel.scss
@@ -62,6 +62,13 @@
background-color: dark-light-diff($highlight, $secondary, 50%, -55%);
}
}
+
+ .new {
+ font-size: 0.8em;
+ margin-left: 0.5em;
+ color: dark-light-choose(scale-color($primary, $lightness: 50%), scale-color($secondary, $lightness: 50%));
+ }
+
}
li.category-link {
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index bb550483d3c..d537c6b7a8f 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -572,7 +572,7 @@ class UsersController < ApplicationController
end
def read_faq
- if(user = current_user)
+ if user = current_user
user.user_stat.read_faq = 1.second.ago
user.user_stat.save
end
diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb
index cc689e42b16..71306753bd1 100644
--- a/app/serializers/current_user_serializer.rb
+++ b/app/serializers/current_user_serializer.rb
@@ -30,12 +30,17 @@ class CurrentUserSerializer < BasicUserSerializer
:dismissed_banner_key,
:is_anonymous,
:post_queue_new_count,
- :show_queued_posts
+ :show_queued_posts,
+ :read_faq
def include_site_flagged_posts_count?
object.staff?
end
+ def read_faq
+ object.user_stat.read_faq?
+ end
+
def topic_count
object.topics.count
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index fd9845690b5..e92de892cfe 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -952,6 +952,7 @@ en:
private_messages: "Search messages"
hamburger_menu: "go to another topic list or category"
+ new_item: "New!"
go_back: 'go back'
not_logged_in_user: 'user page with summary of current activity and preferences'
current_user: 'go to your user page'