You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
5.4 KiB
1 lines
5.4 KiB
define(["jquery"],function(a){var b=function(b){return a.extend(!0,{},b)},c=function(a,b,c){return a.map(function(a){var d=a.useridfrom==b;return{id:parseInt(a.id,10),isRead:a.isread,fromLoggedInUser:d,userFrom:c[a.useridfrom],text:a.text,timeCreated:parseInt(a.timecreated,10)}})},d=function(a){return a.map(function(a){return{id:a.id,fullname:a.fullname,profileurl:a.profileurl,profileimageurl:a.profileimageurl,profileimageurlsmall:a.profileimageurlsmall,isonline:a.isonline,showonlinestatus:a.showonlinestatus,isblocked:a.isblocked,iscontact:a.iscontact,isdeleted:a.isdeleted,canmessage:a.canmessage,requirescontact:a.requirescontact,contactrequests:a.contactrequests||[]}})},e=function(a,b,c){return{midnight:a,loggedInUserId:b,id:c,name:null,subname:null,type:null,totalMemberCount:null,imageUrl:null,isFavourite:null,isMuted:null,canDeleteMessagesForAllUsers:!1,deleteMessagesForAllUsers:!1,members:{},messages:[],hasTriedToLoadMessages:!1,loadingMessages:!0,sendingMessage:!1,loadingMembers:!0,loadingConfirmAction:!1,pendingBlockUserIds:[],pendingUnblockUserIds:[],pendingRemoveContactIds:[],pendingAddContactIds:[],pendingDeleteMessageIds:[],pendingDeleteConversation:!1,selectedMessageIds:[]}},f=function(a,d){var e=b(a),f=c(d,a.loggedInUserId,a.members),g=a.messages.concat(f);return g.sort(function(a,b){return a.timeCreated<b.timeCreated?-1:a.timeCreated>b.timeCreated?1:a.id<b.id?-1:a.id>b.id?1:0}),e.messages=g.filter(function(a,b,c){return!b||a.id!==c[b-1].id}),e},g=function(a,c){var d=b(a),e=c.map(function(a){return a.id});return d.messages=d.messages.filter(function(a){return e.indexOf(a.id)<0}),d},h=function(a,c){var d=b(a);return d.messages=d.messages.filter(function(a){return c.indexOf(a.id)<0}),d},i=function(a,c){var e=b(a),f=d(c);return f.forEach(function(a){e.members[a.id]=a}),e},j=function(a,c){var d=b(a);return c.forEach(function(a){delete d.members[a.id]}),d},k=function(a,c){var d=b(a);return d.loadingMessages=c,a.loadingMessages&&!c&&(d.hasTriedToLoadMessages=!0),d},l=function(a,c){var d=b(a);return d.sendingMessage=c,d},m=function(a,c){var d=b(a);return d.loadingMembers=c,d},n=function(a,c){var d=b(a);return d.id=c,d},o=function(a,c){var d=b(a);return d.name=c,d},p=function(a,c){var d=b(a);return d.subname=c,d},q=function(a,c){var d=b(a);return d.type=c,d},r=function(a,c){var d=b(a);return d.isFavourite=c,d},s=function(a,c){var d=b(a);return d.isMuted=c,d},t=function(a,c){var d=b(a);return d.totalMemberCount=c,d},u=function(a,c){var d=b(a);return d.imageUrl=c,d},v=function(a,c){var d=b(a);return d.loadingConfirmAction=c,d},w=function(a,c){var d=b(a);return d.pendingDeleteConversation=c,d},x=function(a,c){var d=b(a);return c.forEach(function(a){d.pendingBlockUserIds.push(a)}),d},y=function(a,c){var d=b(a);return c.forEach(function(a){d.pendingRemoveContactIds.push(a)}),d},z=function(a,c){var d=b(a);return c.forEach(function(a){d.pendingUnblockUserIds.push(a)}),d},A=function(a,c){var d=b(a);return c.forEach(function(a){d.pendingAddContactIds.push(a)}),d},B=function(a,c){var d=b(a);return c.forEach(function(a){d.pendingDeleteMessageIds.push(a)}),d},C=function(a,c){var d=b(a);return d.pendingBlockUserIds=d.pendingBlockUserIds.filter(function(a){return c.indexOf(a)<0}),d},D=function(a,c){var d=b(a);return d.pendingRemoveContactIds=d.pendingRemoveContactIds.filter(function(a){return c.indexOf(a)<0}),d},E=function(a,c){var d=b(a);return d.pendingUnblockUserIds=d.pendingUnblockUserIds.filter(function(a){return c.indexOf(a)<0}),d},F=function(a,c){var d=b(a);return d.pendingAddContactIds=d.pendingAddContactIds.filter(function(a){return c.indexOf(a)<0}),d},G=function(a,c){var d=b(a);return d.pendingDeleteMessageIds=d.pendingDeleteMessageIds.filter(function(a){return c.indexOf(a)<0}),d},H=function(a,c){var d=b(a);return d.selectedMessageIds=d.selectedMessageIds.concat(c),d},I=function(a,c){var d=b(a);return d.selectedMessageIds=d.selectedMessageIds.filter(function(a){return c.indexOf(a)<0}),d},J=function(a,c){var d=b(a),e=c.map(function(a){return a.id});return d.messages=d.messages.map(function(a){return e.indexOf(a.id)>=0&&(a.isRead=!0),a}),d},K=function(a,c){var d=b(a);return c.forEach(function(a){var b=a.userid,c=a.requesteduserid;d.members[b].contactrequests.push(a),d.members[c].contactrequests.push(a)}),d},L=function(a,c){var d=b(a);return c.forEach(function(a){var b=a.userid,c=a.requesteduserid;d.members[b].contactrequests=d.members[b].contactrequests.filter(function(a){return a.userid!=b}),d.members[c].contactrequests=d.members[c].contactrequests.filter(function(a){return a.requesteduserid!=c})}),d},M=function(a,c){var d=b(a);return d.canDeleteMessagesForAllUsers=c,d},N=function(a,c){var d=b(a);return d.deleteMessagesForAllUsers=c,d};return{buildInitialState:e,addMessages:f,removeMessages:g,removeMessagesById:h,addMembers:i,removeMembers:j,setLoadingMessages:k,setSendingMessage:l,setLoadingMembers:m,setId:n,setName:o,setSubname:p,setType:q,setIsFavourite:r,setIsMuted:s,setCanDeleteMessagesForAllUsers:M,setDeleteMessagesForAllUsers:N,setTotalMemberCount:t,setImageUrl:u,setLoadingConfirmAction:v,setPendingDeleteConversation:w,addPendingBlockUsersById:x,addPendingRemoveContactsById:y,addPendingUnblockUsersById:z,addPendingAddContactsById:A,addPendingDeleteMessagesById:B,removePendingBlockUsersById:C,removePendingRemoveContactsById:D,removePendingUnblockUsersById:E,removePendingAddContactsById:F,removePendingDeleteMessagesById:G,addSelectedMessagesById:H,removeSelectedMessagesById:I,markMessagesAsRead:J,addContactRequests:K,removeContactRequests:L}});
|