Guest User

Untitled

a guest
Feb 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. var Notification = can.DefineMap.extend({
  2. id: "integer",
  3. title: "string",
  4. text: "string",
  5. icon: "string",
  6. date: "string",
  7. looked: "string",
  8. });
  9.  
  10. Notification.List = can.DefineList.extend({
  11. "#": Notification,
  12. });
  13.  
  14.  
  15. Notification.connection = can.connect.superMap({
  16. url: {
  17. resource: '/notifications'
  18. },
  19. Map: Notification,
  20. List: Notification.List,
  21. name: 'notification'
  22. });
  23.  
  24. Notification.getList({}).then(bind(function(value){
  25. this.checkUnviewed(value); // Проверка новых сообщений
  26. this.notifications = value;
  27. }, this));
  28.  
  29. /**
  30. * Проверяет есть ли новое сообщение
  31. * @param array
  32. */
  33. checkUnviewed: function(notifications){
  34. this.unviewed = notifications.some(function(item){
  35. return !item.looked;
  36. });
  37. },
Add Comment
Please, Sign In to add comment