HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Notification bell

This little bell contains only the most recent notifications which after about 2 weeks(?) they all go away and the notification bell then shows nothing but a text message such as 'Notifications will appear here' on the flyout below it.

We however find the shortcuts to 'All Notifications' at the bottom of this flyout menu and the notification preferences icon at the top, rather handy. These links will only be seen when there are recent notifications so, is there a straightforward way to have these two links always show up?



Also, can one configure for how long these notifications are displayed under the notification bell?


I searched forum & docs but couldn't find this, kindly refer me to it if this is explained somewhere, thanks in advance.

v 2021.011

Comments

  • KasparKaspar Moderator

    If you go to "View Profile" then in the right side panel you can access Notifications.

    Direct link

    https://open.vanillaforums.com/profile/notifications

    If you go to "Edit Profile" then in the right side panel you can access Notification Preferences

    Direct link

    https://open.vanillaforums.com/profile/preferences


    You can add a link with Pockets, which is an In-Core plugin

    https://success.vanillaforums.com/kb/articles/366-using-pockets-widgets-to-enhance-your-theme

    faumfaum
  • KasparKaspar Moderator

    <li class="Active Notifications"><a href="/profile/notifications"><span aria-hidden="true" class="Sprite SpNotifications"></span> Notifications</a></li>

    faumfaum
  • KasparKaspar Moderator
    faumfaum
  • Tak Kaspar. Yes, I'm aware of those options. And how about having the bell contain messages older than 2 weeks or have the bell always contain those two links, is that something that could easily be configured, or through a plug-in, or are we in core-hacking territory?

    About your other two messages, I'm not sure I follow, would you please elaborate, or you're just pointing out the link to notifications itself?

    Thanks & good luck against Wales.

  • KasparKaspar Moderator

    I have no idea on how to extend the limit.


    Other posts was to show the html used, so you could re use it in a pocket or know which class'es style it.

    faumfaum
  • R_JR_J Ex-Fanboy Munich Admin

    Core hacking, sorry. Or a complicated and or messy plugin.

    The "2 weeks" can be found in the ProfileController:

    public function notificationsPopin($transientKey = '') {
      $this->permission('Garden.SignIn.Allow');
    
      if (Gdn::session()->validateTransientKey($transientKey) !== true) {
          throw new Gdn_UserException(t('Invalid CSRF token.', 'Invalid CSRF token. Please try again.'), 403);
      }
    
      $where = [
          'NotifyUserID' => Gdn::session()->UserID,
          'DateUpdated >=' => Gdn_Format::toDateTime(strtotime('-2 weeks'))
      ];
    
      $this->ActivityModel = new ActivityModel();
      $activities = $this->ActivityModel->getWhere($where, '', '', 5, 0)->resultArray();
      $this->setData('Activities', $activities);
      $this->ActivityModel->markRead(Gdn::session()->UserID);
    
      $this->setData('Title', t('Notifications'));
      $this->render('Popin', 'Activity', 'Dashboard');
    

    }

    As you can see, there is no event fired that can be used. But /profile/notificationspopin is called from the view. That should be "/applications/dashboard/views/modules/me.php", but I also see some React components which might be used in some themes. I'm a little bit lost when it comes to React.

    The plugin-way would be to create a plugin that needs to copy the notificationsPopin code with just another time period (or none at all) and to take care that the link to your plugin is shown instead of /profile/notificationspopin. That can be achieved by using a some javascript which changes the link after the page has been loaded or by using a custom view, which would be a copy of the me.php with just the link to the notificationspopin tweaked to point to your plugin.

    If a plugin does nothing more than duplicating views and methods with only micro-tweaks, I would think it might be prefferable to change the source code - and I really don't say so often.


    The ultimativly best solution would be if that line above would read: 'DateUpdated >=' => Gdn_Format::toDateTime(strtotime('-'.Gdn::config('Garden.Profile.MaxNotificationPeriod', '2 weeks')))

    You wouldn't be able to disable that, but setting it to "100 years" in your config would serve the same purpose. You might try your luck and create a Pull Request on GitHub for that.


    faumfaum
  •  I would think it might be prefferable to change the source code - and I really don't say so often.

    Oh I believe you, I've seen the mild scoldings -not just yours- to core-hacker wannabes in this forum, but hey they do work. The scoldings I mean.

    Garden.Profile.MaxNotificationPeriod
    

    Having this configuration option would be lit yeah. But let me ask you since you seem very knowledgeable about developing Vanilla, how would you feel about just adding html to the translation file? Minimum markup -no css- just to add the needed link/s in a case like this?

    It's a minimum effort workaround, rather easy to maintain but quite dirty yes. Scolding?

    Herzlichen vielen Dank.

  • R_JR_J Ex-Fanboy Munich Admin

    Sorry, I don't get what you are thinking of, could you be a little bit more precise as to what you want to change where?


    faumfaum
  • And how about having the bell contain messages older than 2 weeks or have the bell always contain those two links

    I was referring to the bold part. If I were to have the validity of those notifications extended I would do it mainly so that the bell flyout menu contains those two handy shortcut links.

    If you say that extending the lifespan of these notifications is rather messy or involves core-hacking (let's forget about the pull request for a sec) then, how would you feel about bringing those two links into the language file?

    Basically, just turning this...

    $Definition['Notifications will appear here.'] = 'Notifications will appear here';
    

    ...into something like this

    $Definition['Notifications will appear here.'] = 'Notifications will appear here<a href="/profile/notifications">All Notifications</a>';
    


    Would this be preferable to core-hacking or is this also a no-no when customizing Vanilla?

    Thanks again.

  • R_JR_J Ex-Fanboy Munich Admin

    That's how it looks like in my installation:

    I don't think adding another link is necessary, but that text is misleading in some cases. The original text "Notifications will appear here." might be better translated with "There have been no notifications since two weeks"

    There are mainly two reasons why core files shouldn't be changed:

    1. Changes are lost on every update and you need to redo your changes again
    2. Changed functionality might lead to breaking the forum altogether

    Changing translations never hurt in any way, so translate it in any way that you think it makes it clearer to your users


    faumfaum

  • Did you customize this? On my vanilla Vanilla instances -dev, test & live all starting from 3.3. to .011- I've never seen those links show up when there's no notifications in the bell flyout menu. I only always got the string message 'You do not have...' in a smaller flyout menu without any clickable links in it.

    And the 'Mark All Read' is something I don't have at all, ever, first time seeing it actually. Even this instance at open.vanillaforums.com doesn't seem to have it.

    How'd you do that?

  • R_JR_J Ex-Fanboy Munich Admin

    Okay, I see! That's a screenshot of the Foundation theme. I checked Keystone theme now and that notification popup only contains one sentence.

    Sadfully implementing that new style is not as trivial as copying one file to a custom theme. Foundation makes use of React components heavily. That part is taken from here: library/src/scripts/headers/mebox/pieces/NotificationsContentsImpl.tsx

    But nevertheless you should be able to create a custom me.php view which includes this changes.


    faumfaum
  • Right, my bad for not mentioning I was on a keystone base theme and not on the new foundation.

    I will eventually migrate to the foundation, mostly for taking full advantage of the new advanced search page so I won't mess with my theme in that way for now. Thanks for bearing with me rj.

  • R_JR_J Ex-Fanboy Munich Admin

    In case that you would like to customize your theme , I would recommend to not use Foundation. The frontend is built from React components. As long as you are not fluent with the JavaScript eco-system (React, TypeScript, yarn at least) everything becomes somewhat un-managable.

    Just take the above as an example: if you want to customize the me-box with keystone, you need to create a file in your theme called views/modules/me.php - easy as that. As you have seen above, it is a TypeScript React component in Foundation. That means that if you want to use your React component, you need to recompile some assets. Since I don't know much about React, I cannot tell if swapping a component is easy or not. But the fact that me as an experienced Vanilla developer is absolutely clueless about the theme also shows how much it is different from what could be found in Vanilla until now.

    Another example. Foundation comes with a "Quick Links" widget and guess what the class names of the list entries in that widget are! div.pageBoxNoCompat css-18ts849-PageBox-boxClass > nav > ul.vanilla-lfbjtw-quickLinks-list no-css > li.vanilla-1mmg9nn-quickLinks-listItem

    Happy styling... Of course with some tweaking of source sass files and recompiling again it could be done. If you know how.

    Furthermore after each new release of Vanilla, it wouldn't be as easy a to copy the new release files to your installation, but you would need to recompile all assets by yourself.


    Yepp. Compiling, compiling, compiling. Everybody is happy with that new JavaScript world because it is so powerful and I agree that it is really impressive. But it feels limiting, too. A React powered UI may allow some simple tweaks in some kind of settings section. But beyond that, you need to get your hands dirty and build up good knowledge of how that compiling process works and all languages that are needed in that process. Looking at the code base gives you an impression of what technologies seems to get important:

    PHP < 50% - unbelievable...

    By now the usage of React doesn't make much sense because the big advantage - reactivity - is only in very few places. But I hope that this is an evolution and it would reach a point where you come to a nearly SPA like experience. In order to have a great feature like that, the downside is a JavaScript heavy project. Poor me :-( But that's why I try my hands on Quasar and hopefully get some more knowledge on that behated JS ;-)


    faumfaum
Sign In or Register to comment.