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 line
9.7 KiB

define(["jquery","core/user_date","core_message/message_drawer_view_conversation_constants"],function(a,b,c){var d=function(a,c){var d=a.reduce(function(a,d){var e=b.getUserMidnightForTimestamp(d.timeCreated,c);return a.hasOwnProperty(e)?a[e].push(d):a[e]=[d],a},{});return Object.keys(d).map(function(a){return{timestamp:a,messages:d[a]}})},e=function(a,b,c){b=b.slice();var d=[],e=[],f=[];return a.forEach(function(a){for(var d=!1,g=0;g<b.length;g++){var h=b[g];if(c(a,h)){d=!0,f.push({a:a,b:h});break}}d?b.splice(g,1):e.push(a)}),d=b,{missingFromA:d,missingFromB:e,matches:f}},f=function(a,b){for(var c=null,d=0;d<a.length;d++){var e=a[d];if(b(e))return e}return c},g=function(a,b){a.sort(),b.sort();var c=a.length,d=b.length;return c<1&&d<1||c==d&&a.every(function(a,c){return a==b[c]})},h=function(a,b){return{remove:b.missingFromB,add:b.missingFromA.map(function(b){var c=f(a,function(a){return b.timestamp<a.timestamp});return{before:c,value:b}})}},i=function(a){var b=[],c=[];return a.forEach(function(a){var d=a.a,g=a.b,h=e(d.messages,g.messages,function(a,b){return a.id==b.id});b=b.concat(h.missingFromB),h.missingFromA.forEach(function(a){var b=f(d.messages,function(b){return a.timeCreated==b.timeCreated?a.id<b.id:a.timeCreated<b.timeCreated});c.push({before:b,value:a,day:d})})}),{add:c,remove:b}},j=function(a,b){var c=a.messages.map(function(a){return a.id}),f=b.messages.map(function(a){return a.id});if(g(c,f))return null;var j=d(a.messages,a.midnight),k=d(b.messages,b.midnight),l=e(j,k,function(a,b){return a.timestamp==b.timestamp});return{days:h(j,l),messages:i(l.matches)}},k=function(a,b){var d=I(a,b),e=y(a,b),f=G(a),g=G(b),h=d&&d.show&&!d.hasMessages,i=d&&!d.show,j=!f&&g;return j=j||h||i,j=j||null!==e,j?{type:c.CONVERSATION_TYPES.PRIVATE,showControls:!h&&!e,context:{id:b.id,name:b.name,subname:b.subname,totalmembercount:b.totalMemberCount,imageurl:b.imageUrl,isfavourite:b.isFavourite,ismuted:b.isMuted,showfavourite:null!==b.id,userid:g.id,showonlinestatus:g.showonlinestatus,isonline:g.isonline,isblocked:g.isblocked,iscontact:g.iscontact}}:null},l=function(a,b){var d=null===a.name&&null!==b.name;return d?{type:c.CONVERSATION_TYPES.SELF,showControls:!1,context:{id:b.id,name:b.name,subname:b.subname,imageurl:b.imageUrl,isfavourite:b.isFavourite,showfavourite:null!==b.id,showonlinestatus:!0}}:null},m=function(a,b){var d=a.totalMemberCount,e=b.totalMemberCount;return d!=e?{type:c.CONVERSATION_TYPES.PUBLIC,showControls:!0,context:{id:b.id,name:b.name,subname:b.subname,totalmembercount:b.totalMemberCount,imageurl:b.imageUrl,isfavourite:b.isFavourite,ismuted:b.isMuted,showfavourite:null!==b.id}}:null},n=function(a,b){var c=a.messages,d=b.messages;if(d.length<1)return null;if(c.length<1)return d[d.length-1].id;var e=c[a.messages.length-1],f=d[d.length-1],g=c[0],h=d[0];return e.id!=f.id?f.id:g.id!=h.id?g.id:null},o=function(a,b){return!(a.loadingMembers||!b.loadingMembers)||!(a.loadingMembers&&!b.loadingMembers)&&null},p=function(a,b){return a.hasTriedToLoadMessages===b.hasTriedToLoadMessages?null:!(b.hasTriedToLoadMessages||!b.loadingMessages)||!(b.hasTriedToLoadMessages&&!b.loadingMessages)&&null},q=function(a,b){return!(a.loadingMessages||!b.loadingMessages)||!(a.loadingMessages&&!b.loadingMessages)&&null},r=function(a,b){return!(a.sendingMessage||!b.sendingMessage)||!(a.sendingMessage&&!b.sendingMessage)&&null},s=function(a,b){if(b.pendingBlockUserIds.length){var c=b.pendingBlockUserIds[0];return b.members[c]}return!a.pendingBlockUserIds.length&&null},t=function(a,b){if(b.pendingUnblockUserIds.length){var c=b.pendingUnblockUserIds[0];return b.members[c]}return!a.pendingUnblockUserIds.length&&null},u=function(a,b){if(b.pendingAddContactIds.length){var c=b.pendingAddContactIds[0];return b.members[c]}return!a.pendingAddContactIds.length&&null},v=function(a,b){if(b.pendingRemoveContactIds.length){var c=b.pendingRemoveContactIds[0];return b.members[c]}return!a.pendingRemoveContactIds.length&&null},w=function(a,b){var c=a.pendingDeleteMessageIds.length,d=b.pendingDeleteMessageIds.length;return d&&!c?{show:!0,type:b.type,canDeleteMes