Fandom

Wikia Developers Wiki

Nirvana Controller for Unread Message Wall Threads

  • Does anyone know the name of the Nirvana controller/method combo that lists the thread numbers of a user's unread message wall notifications? I thought the method in question was under WallNotificationsExternal or WallExternal, but neither of those have the method I need. I suppose I could sift through wikia/WallNotifications, but I figured I'd post here first.

      Loading editor
    • You missed it :P
      $.nirvana.getJson('WallNotificationsExternal', 'getUpdateCounts', d => console.log(d.count));
      P.S. always use format=json if you want to take actual data. Also, method=help is usually useless
        Loading editor
    • No, I know that one exists (and I've even used it before). That provides the number of unread messages, but I'm looking for the method that actually provides the thread numbers (i.e. Thread:705) of unread notifications. Is there such a method?

        Loading editor
    • That would be a liiiiiiitle bit hackier

      $.nirvana.getJson('WallNotificationsExternal', 'getUpdateCounts', function(d) {
          var wikis = $(d.html).find('.notifications-for-wiki').map(function() {
              return $(this).data('wiki-id');
          }).toArray(), temp = 0, data = {};
          wikis.forEach(function(el) {
              $.nirvana.getJson('WallNotificationsExternal', 'getUpdateWiki', {
                  wikiId: el,
                  isCrossWiki: 1
              }, function(d) {
                  $(d.html).filter('.unread').find('a').each(function() {
                      var res = /http:\/\/(\w+)\.wikia\.com\/wiki\/.*:(\d+)/.exec($(this).attr('href')),
                          wiki = res[1];
                      data[wiki] = data[wiki] || [];
                      data[wiki].push(Number(res[2]));
                  });
                  if(++temp === wikis.length) {
                      // All requests finished
                      console.log(data);
                  }
              });
          });
      });

      The above returns an object like

      {
          "wikisubdomain": [
              threadid,
              threadid2,
              threadid3
          ],
          "wikisubdomain2": [
              threadid,
              threadid2
          ]
      }
        Loading editor
    • I tried something similar but significantly less effective. I was grabbing the html of the user dropdown menu and manually extracting the href from .notifications-for-wiki-list a. Thanks a bunch, Cube.

      Shame there isn't a proper method for this.

        Loading editor
    • But .notifications-for-wiki-list a doesn't even exist... did you mean some other element?

      Edit: Oh you meant from DOM... that's even faster...

        Loading editor
    • $('#GlobalNavigationWallNotifications .notifications-for-wiki .notifications-for-wiki-list a')[0];

      It's in the user dropdown menu. I was getting desperate.

        Loading editor
    • You don't actually need to send an HTTP request for that unless the notifications haven't loaded, though. You could try taking it from DOM and if that fails send an HTTP request to Nirvana.

      Unless you want to automatically refresh the data about current notifications, then you should always use Nirvana, I suppose.

        Loading editor
    • Therein lies the problem. I was planning on constantly acquiring notification data over a set interval, hence the need for a Nirvana controller. I suppose I could use setInterval to refresh the #GlobalNavigationWallNotifications menu, but that's a pretty hacky method in my opinion.

        Loading editor
    • A Fandom user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.