ChannelCollection.js

From disqus.com, 1 Week ago, written in JavaScript, viewed 3 times. This paste is a reply to LinkPopover.js from disqus.com - view diff
URL https://pastebin.freepbx.org/view/e974894e Embed
Download Paste or View Raw
  1. define('core/collections/ChannelCollection',[
  2.     'underscore',
  3.  
  4.     'core/collections/PaginatedCollection',
  5.     'core/UniqueModel',
  6.     'core/api',
  7.     'core/models/Channel',
  8.     'core/utils/objectExpander',
  9. ], function (
  10.     _,
  11.  
  12.     PaginatedCollection,
  13.     UniqueModel,
  14.     api,
  15.     Channel,
  16.     objectExpander
  17. ) {
  18.     'use strict';
  19.  
  20.     var ChannelCollection = PaginatedCollection.extend({
  21.         url: api.getURL('channels/list'),
  22.  
  23.         model: UniqueModel.boundModel(Channel),
  24.  
  25.         initialize: function (_models, options) {
  26.             PaginatedCollection.prototype.initialize.call(this, _models, options);
  27.             options = options || {};
  28.             this.listName = options.listName;
  29.         },
  30.  
  31.         fetch: function (options) {
  32.             options = options || {};
  33.  
  34.             if (this.listName)
  35.                 options.data = _.extend({ listName: this.listName }, options.data);
  36.  
  37.             return PaginatedCollection.prototype.fetch.call(this, options);
  38.         },
  39.  
  40.         parse: function (response) {
  41.             if (Boolean(response) && Boolean(response.response) && _.isArray(response.response)) {
  42.                 response = _.defaults({ response: _.filter(response.response, function (channel) {
  43.                     return !channel || !channel.primaryForum || !channel.primaryForum.id ||
  44.                         channel.primaryForum.id === 'channel-discussdisqus';
  45.                 }) }, response);
  46.             }
  47.  
  48.             response = PaginatedCollection.prototype.parse.call(this, response);
  49.  
  50.             // Some endpoints use reference/objects mapping for channels, which are handled
  51.             // differently.
  52.             if (response.items) {
  53.                 return _.map(response.items, function (listedChannel) {
  54.                     return objectExpander.buildChannel(response.objects, listedChannel.reference);
  55.                 });
  56.             }
  57.  
  58.             return response;
  59.         },
  60.     });
  61.  
  62.     return ChannelCollection;
  63. });
  64.  
  65. // https://c.disquscdn.com/next/next-core/core/collections/ChannelCollection.js

Replies to ChannelCollection.js rss

Title Name Language When
ediaCollection.js disqus.com javascript 1 Week ago.

Reply to "ChannelCollection.js"

Here you can reply to the paste above