pixelfed/public/js/activity.js
2019-06-03 17:51:48 -06:00

1 line
7.8 KiB
JavaScript
Vendored

!function(t){var e={};function a(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,a),o.l=!0,o.exports}a.m=t,a.c=e,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)a.d(n,o,function(e){return t[e]}.bind(null,o));return n},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="/",a(a.s=1)}({1:function(t,e,a){t.exports=a("hUgz")},"KHd+":function(t,e,a){"use strict";function n(t,e,a,n,o,i,r,s){var c,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=a,l._compiled=!0),n&&(l.functional=!0),i&&(l._scopeId="data-v-"+i),r?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(r)},l._ssrRegister=c):o&&(c=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),c)if(l.functional){l._injectStyles=c;var u=l.render;l.render=function(t,e){return c.call(e),u(t,e)}}else{var f=l.beforeCreate;l.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:l}}a.d(e,"a",function(){return n})},hUgz:function(t,e,a){Vue.component("activity-component",a("tXHz").default)},tXHz:function(t,e,a){"use strict";a.r(e);function n(t){return function(t){if(Array.isArray(t)){for(var e=0,a=new Array(t.length);e<t.length;e++)a[e]=t[e];return a}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var o={data:function(){return{notifications:{},notificationCursor:2,notificationMaxId:0}},mounted:function(){this.fetchNotifications()},updated:function(){$('[data-toggle="tooltip"]').tooltip()},methods:{fetchNotifications:function(){var t=this;axios.get("/api/v1/notifications").then(function(e){var a=e.data.filter(function(t){return!("share"==t.type&&!status)}),o=e.data.map(function(t){return t.id});t.notificationMaxId=Math.max.apply(Math,n(o)),t.notifications=a,$(".notification-card .loader").addClass("d-none"),$(".notification-card .contents").removeClass("d-none")})},infiniteNotifications:function(t){var e=this;this.notificationCursor>10?t.complete():axios.get("/api/v1/notifications",{params:{page:this.notificationCursor}}).then(function(a){if(a.data.length){var o,i=a.data.filter(function(t){return!("share"==t.type&&!status)});(o=e.notifications).push.apply(o,n(i)),e.notificationCursor++,t.loaded()}else t.complete()})},truncate:function(t){return t.length<=15?t:t.slice(0,15)+"..."},timeAgo:function(t){var e=Date.parse(t),a=Math.floor((new Date-e)/1e3),n=Math.floor(a/31536e3);return n>=1?n+"y":(n=Math.floor(a/604800))>=1?n+"w":(n=Math.floor(a/86400))>=1?n+"d":(n=Math.floor(a/3600))>=1?n+"h":(n=Math.floor(a/60))>=1?n+"m":Math.floor(a)+"s"},mentionUrl:function(t){return"/p/"+t.account.username+"/"+t.id},followProfile:function(t){var e=this,a=t.account.id;axios.post("/i/follow",{item:a}).then(function(t){e.notifications.map(function(t){t.account.id===a&&(t.relationship.following=!0)})}).catch(function(t){t.response.data.message&&swal("Error",t.response.data.message,"error")})},viewContext:function(t){switch(t.type){case"follow":return t.account.url;case"mention":return t.status.url;case"like":case"favourite":return t.status.url}return"/"}}},i=a("KHd+"),r=Object(i.a)(o,function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"container"},[a("div",{staticClass:"row my-5"},[a("div",{staticClass:"col-12 col-md-8 offset-md-2"},[t._l(t.notifications,function(e,n){return t.notifications.length>0?a("div",{staticClass:"media mb-3 align-items-center px-3 border-bottom pb-3"},[a("img",{staticClass:"mr-2 rounded-circle",staticStyle:{border:"1px solid #ccc"},attrs:{src:e.account.avatar,alt:"",width:"32px",height:"32px"}}),t._v(" "),a("div",{staticClass:"media-body font-weight-light"},["favourite"==e.type?a("div",[a("p",{staticClass:"my-0"},[a("a",{staticClass:"font-weight-bold text-dark word-break",attrs:{href:e.account.url,"data-placement":"bottom","data-toggle":"tooltip",title:e.account.username}},[t._v(t._s(t.truncate(e.account.username)))]),t._v(" liked your "),a("a",{staticClass:"font-weight-bold",attrs:{href:e.status.url}},[t._v("post")]),t._v(".\n\t\t\t\t\t\t\t")])]):"comment"==e.type?a("div",[a("p",{staticClass:"my-0"},[a("a",{staticClass:"font-weight-bold text-dark word-break",attrs:{href:e.account.url,"data-placement":"bottom","data-toggle":"tooltip",title:e.account.username}},[t._v(t._s(t.truncate(e.account.username)))]),t._v(" commented on your "),a("a",{staticClass:"font-weight-bold",attrs:{href:e.status.url}},[t._v("post")]),t._v(".\n\t\t\t\t\t\t\t")])]):"mention"==e.type?a("div",[a("p",{staticClass:"my-0"},[a("a",{staticClass:"font-weight-bold text-dark word-break",attrs:{href:e.account.url,"data-placement":"bottom","data-toggle":"tooltip",title:e.account.username}},[t._v(t._s(t.truncate(e.account.username)))]),t._v(" "),a("a",{staticClass:"font-weight-bold",attrs:{href:t.mentionUrl(e.status)}},[t._v("mentioned")]),t._v(" you.\n\t\t\t\t\t\t\t")])]):"follow"==e.type?a("div",[a("p",{staticClass:"my-0"},[a("a",{staticClass:"font-weight-bold text-dark word-break",attrs:{href:e.account.url,"data-placement":"bottom","data-toggle":"tooltip",title:e.account.username}},[t._v(t._s(t.truncate(e.account.username)))]),t._v(" followed you.\n\t\t\t\t\t\t\t")])]):"share"==e.type?a("div",[a("p",{staticClass:"my-0"},[a("a",{staticClass:"font-weight-bold text-dark word-break",attrs:{href:e.account.url,"data-placement":"bottom","data-toggle":"tooltip",title:e.account.username}},[t._v(t._s(t.truncate(e.account.username)))]),t._v(" shared your "),a("a",{staticClass:"font-weight-bold",attrs:{href:e.status.reblog.url}},[t._v("post")]),t._v(".\n\t\t\t\t\t\t\t")])]):t._e(),t._v(" "),a("div",{staticClass:"align-items-center"},[a("span",{staticClass:"small text-muted",attrs:{"data-toggle":"tooltip","data-placement":"bottom",title:e.created_at}},[t._v(t._s(t.timeAgo(e.created_at)))])])]),t._v(" "),a("div",[e.status&&e.status&&e.status.media_attachments&&e.status.media_attachments.length?a("div",[a("a",{attrs:{href:e.status.url}},[a("img",{attrs:{src:e.status.media_attachments[0].preview_url,width:"32px",height:"32px"}})])]):e.status&&e.status.parent&&e.status.parent.media_attachments&&e.status.parent.media_attachments.length?a("div",[a("a",{attrs:{href:e.status.parent.url}},[a("img",{attrs:{src:e.status.parent.media_attachments[0].preview_url,width:"32px",height:"32px"}})])]):a("div",[a("a",{staticClass:"btn btn-outline-primary py-0 font-weight-bold",attrs:{href:t.viewContext(e)}},[t._v("View")])])])]):t._e()}),t._v(" "),t.notifications.length?a("div",[a("infinite-loading",{on:{infinite:t.infiniteNotifications}},[a("div",{staticClass:"font-weight-bold",attrs:{slot:"no-results"},slot:"no-results"}),t._v(" "),a("div",{staticClass:"font-weight-bold",attrs:{slot:"no-more"},slot:"no-more"})])],1):t._e(),t._v(" "),0==t.notifications.length?a("div",{staticClass:"text-lighter text-center py-3"},[t._m(0),t._v(" "),a("p",{staticClass:"mb-0 small font-weight-bold"},[t._v("0 Notifications!")])]):t._e()],2)])])])},[function(){var t=this.$createElement,e=this._self._c||t;return e("p",{staticClass:"mb-0"},[e("i",{staticClass:"fas fa-inbox fa-3x"})])}],!1,null,null,null);e.default=r.exports}});