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
6.7 KiB
1 line
6.7 KiB
2 years ago
|
define(["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/str","core/templates","core/user_date","core_message/message_repository","core_message/message_drawer_events","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_lazy_load_list","core_message/message_drawer_view_conversation_constants"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={TOGGLE:'[data-region="toggle"]',CONVERSATION:"[data-conversation-id]",BLOCKED_ICON_CONTAINER:'[data-region="contact-icon-blocked"]',LAST_MESSAGE:'[data-region="last-message"]',LAST_MESSAGE_DATE:'[data-region="last-message-date"]',MUTED_ICON_CONTAINER:'[data-region="muted-icon-container"]',UNREAD_COUNT:'[data-region="unread-count"]',SECTION_TOTAL_COUNT:'[data-region="section-total-count"]',SECTION_TOTAL_COUNT_CONTAINER:'[data-region="section-total-count-container"]',SECTION_UNREAD_COUNT:'[data-region="section-unread-count"]',PLACEHOLDER_CONTAINER:'[data-region="placeholder-container"]'},o={CONVERSATIONS_LIST:"core_message/message_drawer_conversations_list",CONVERSATIONS_LIST_ITEMS_PLACEHOLDER:"core_message/message_drawer_conversations_list_items_placeholder"},p=50,q={},r=!1,s=!1,t=function(a){return l.getRoot(a).hasClass("show")},u=function(a){a.addClass("expanded")},v=function(a){a.removeClass("expanded")},w=function(a,b){var c=a.find(n.SECTION_TOTAL_COUNT_CONTAINER),d=c.find(n.SECTION_TOTAL_COUNT);d.text(b),c.removeClass("hidden"),e.get_string("totalconversations","core_message",b).done(function(a){c.attr("aria-label",a)});var g=b>20?20:b,h=Array.apply(null,Array(g)).map(function(){return!0});f.render(o.CONVERSATIONS_LIST_ITEMS_PLACEHOLDER,{placeholders:h}).then(function(b){var c=a.find(n.PLACEHOLDER_CONTAINER);c.html(b)})["catch"](function(){})},x=function(a,b){var c=a.find(n.SECTION_UNREAD_COUNT);c.text(b),e.get_string("unreadconversations","core_message",b).done(function(a){c.attr("aria-label",a)}),b>0&&c.removeClass("hidden")},y=function(b){var c=function(b){return Object.keys(b).reduce(function(d,e){return a.isArray(b[e])?d[e.toLowerCase()]=b[e].map(c):d[e.toLowerCase()]=b[e],d},{})},d=c(b);return d.messages=d.messages.map(function(a){return a.useridfrom=a.userfrom.id,a}),d},z=function(b,c){var d=b.map(function(b){var d=b.messages.length?b.messages[b.messages.length-1]:null,e={id:b.id,imageurl:b.imageurl,name:b.name,subname:b.subname,unreadcount:b.unreadcount,ismuted:b.ismuted,lastmessagedate:d?d.timecreated:null,sentfromcurrentuser:d?d.useridfrom==c:null,lastmessage:d?a(d.text).text()||d.text:null},f=null;return b.type==m.CONVERSATION_TYPES.SELF?f=b.members[0]:b.type==m.CONVERSATION_TYPES.PRIVATE&&(f=b.members.reduce(function(a,b){return a||b.id==c||(a=b),a},null)),null!==f&&(e.userid=f.id,e.showonlinestatus=f.showonlinestatus,e.isonline=f.isonline,e.isblocked=f.isblocked),b.type==m.CONVERSATION_TYPES.PUBLIC&&(e.lastsendername=b.members.reduce(function(a,b){return!a&&d&&b.id==d.useridfrom&&(a=b.fullname),a},null)),e});return d.forEach(function(a){(new Date).toDateString()==new Date(1e3*a.lastmessagedate).toDateString()&&(a.istoday=!0)}),f.render(o.CONVERSATIONS_LIST,{conversations:d})},A=function(a,b,d){var e=null,f=!0;if(a&&a.length){var g=a.filter(function(a){return a!=m.CONVERSATION_TYPES.SELF});f=a.length!=g.length,e=g[0]}return function(a,g){return h.getConversations(g,e,p+1,d,b,f).then(function(b){var c=b.conversations;return c.length>p?c=c.slice(0,-1):l.setLoadedAll(a,!0),d+=p,c.forEach(function(a){q[a.id]=a}),c})["catch"](c.exception)}},B=function(a){return a.find(n.SECTION_TOTAL_COUNT)},C=function(a){return a.find(n.SECTION_UNREAD_COUNT)},D=function(a){if(r){var b=B(a),c=parseInt(b.text());c+=1,b.text(c)}},E=function(a){if(r){var b=B(a),c=parseInt(b.text());c-=1,b.text(c)}},F=function(a){if(s){var b=C(a),c=parseInt(b.text());c-=1,b.text(c),c<1&&b.addClass("hidden")}},G=function(a,b){return a.find('[data-conversation-id="'+b+'"]')},H=function(a,b){return a.find('[data-user-id="'+b+'"]')},I=function(a){a.find(n.MUTED_ICON_CONTAINER).removeClass("hidden")},J=function(a){a.find(n.MUTED_ICON_CONT
|