Skip to content

Commit

Permalink
patch: notifications (#1281)
Browse files Browse the repository at this point in the history
* v

* v

* v
  • Loading branch information
maxgithubprofile authored Sep 3, 2024
1 parent b31df5a commit 8e572d9
Show file tree
Hide file tree
Showing 26 changed files with 325 additions and 60 deletions.
7 changes: 7 additions & 0 deletions components/channel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ var channel = (function(){
el.c.find('.blockWrapper').on('click', function(){
actions.blocking()
})

if(ed.customaction){
el.c.find('.customaction').on('click', function(){
ed.customaction.action(author.data)
})
}


_.each(reports, function(r, j){
if(r.events){
Expand Down
8 changes: 8 additions & 0 deletions components/channel/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@

<% } %>

<% if(ed.customaction) {%>
<div class="openprofilebuttonwrapper">
<button class="button openprofilebutton customaction">
<%- e(ed.customaction.label) %>
</button>
</div>
<% } %>


<% if(ed.followbutton && !app.curation()) { %>

Expand Down
62 changes: 62 additions & 0 deletions components/earnings/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
#earnings .monetizationChange {
padding-top: 1em;
}
#earnings .monetizationChange .exchangesProfiles {
display: flex;
padding: 1em;
}
#earnings .monetizationChange .exchange {
padding: 0.5em;
background: rgba(var(--background-main), 0.5);
max-width: 300px;
margin-right: 0.5em;
opacity: 0;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
}
#earnings .monetizationChange .exchange.loaded {
opacity: 1;
}
#earnings .monetizationChange .exchange #channel .channel {
position: relative;
background: transparent;
}
#earnings .monetizationChange .exchange #channel .channel .icon {
position: absolute;
right: 0;
top: 0;
}
#earnings .monetizationChange .exchange #channel .channel .icon .usericon {
width: 22px;
height: 22px;
line-height: 22px;
}
#earnings .monetizationChange .exchange #channel .channel .usericon {
margin-left: 0;
}
#earnings .monetizationChange .exchange #channel .channel .userinfo {
flex-flow: column;
}
#earnings .monetizationChange .exchange #channel .channel .userinfo .openprofilebutton {
min-width: 0;
}
#earnings .monetizationChange .exchange .panel [menuitem="posts"],
#earnings .monetizationChange .exchange .panel [menuitem="followers"],
#earnings .monetizationChange .exchange .panel [menuitem="following"] {
display: none;
}
#earnings .monetizationChange .exchange .blockWrapper {
display: none;
}
#earnings .monetizationEnablePreview {
text-align: center;
padding: 2em;
Expand Down Expand Up @@ -410,6 +462,16 @@
#earnings {
min-height: none;
}
#earnings .monetization .monetizationChange .exchangesProfiles {
display: flex;
flex-flow: column;
padding: 1em;
}
#earnings .monetization .monetizationChange .exchangesProfiles .exchange {
max-width: none;
margin-right: 0;
margin-bottom: 1em;
}
#earnings .monetization .disableMonetization {
margin-right: 0.5em;
}
Expand Down
87 changes: 65 additions & 22 deletions components/earnings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ var earnings = (function () {
startPeriod : 1725235200,
periodDuration : 'w',
groupDuration : 'm',
years : [2023, new Date().getFullYear()]
years : [2023, new Date().getFullYear()],
exchanges : ['PMZ3DiGWKGybLb5oCz9ojwxuTBA6GcYAKq', 'PLpzAiA6H8isp33WeVx2UEuXLfc3SyqkzK']
}

console.log('monetizationParameters', monetizationParameters)
var address = ''

var stats = []
var monetizationOpportunity = false
Expand Down Expand Up @@ -73,11 +74,11 @@ var earnings = (function () {
},
getEarnings : function(){
return self.app.monetization.contentperformance({
addresses : [self.app.user.address.value],
addresses : [address],
...helpers.getYearPeriod(monetizationParameters.currentYear)
}).then((result = {}) => {

var r = result[self.app.user.address.value] || []
var r = result[address] || []

var weeks = _.sortBy(weeksInYear(monetizationParameters.currentYear), (w) => {
return -w.n
Expand All @@ -86,9 +87,6 @@ var earnings = (function () {
var weeksResult = _.map(weeks, (w) => {

var posts = _.filter(r, (f) => {

console.log('getWeekNumber(moment.utc(f.time).toDate())[1]', moment.utc(f.time).toDate(), getWeekNumber(moment.utc(f.time).toDate())[1])

return getWeekNumber(new Date(moment.utc(f.time * 1000).toDate()))[1] == w.n
})

Expand Down Expand Up @@ -162,7 +160,14 @@ var earnings = (function () {

getStat: async function () {

return self.app.api.rpc('getaccountearning', [self.user.address.value, 0, 1627534]).then(function (r) {
if(address != self.user.address.value){

el.content.empty();

return Promise.resolve()
}

return self.app.api.rpc('getaccountearning', [address, 0, 1627534]).then(function (r) {

el.content.empty();

Expand Down Expand Up @@ -370,16 +375,49 @@ var earnings = (function () {
})
},

exchanges(el, clbk){

_.each(monetizationParameters.exchanges, (address) => {

var cel = el.find('.exchange[address="'+address+'"]')

self.nav.api.load({
open : true,
id : 'channel',
el : cel,
eid : 'earnings_' + address,
essenseData : {
id : address,
customaction : {
label : 'monetization_buychat',
action : function(profile){
console.log('profile', profile)

self.app.platform.matrixchat.startchat(profile.address)
}
}
},

clbk : function(){
cel.addClass('loaded')
}
})
})
},

monetizationWrapper(clbk){

console.log('monetizationOpportunity', monetizationOpportunity, address)

if(!monetizationOpportunity){
if(clbk) clbk()

return
}

self.app.platform.sdk.users.checkMonetization(self.app.user.address.value).then((monetization) => {
self.app.platform.sdk.users.checkMonetization(address).then((monetization) => {

console.log('monetizationOpportunity2', monetization, address)


self.shell({
Expand All @@ -393,6 +431,8 @@ var earnings = (function () {

}, function (_p) {

renders.exchanges(_p.el.find('.exchangesProfiles'))

_p.el.find('.yearleft').on('click', function(){
monetizationParameters.currentYear --

Expand All @@ -417,7 +457,6 @@ var earnings = (function () {

})


_p.el.find('.disableMonetization').on('click', function(){

new dialog({
Expand All @@ -442,13 +481,9 @@ var earnings = (function () {
class : 'zindex'
})



})




if (monetization){

var elm = _p.el.find('.monetizationEarnings')
Expand All @@ -469,6 +504,8 @@ var earnings = (function () {
renders.error(elm)
})
}



if(clbk) clbk(monetization)

Expand Down Expand Up @@ -510,17 +547,23 @@ var earnings = (function () {

getdata: async function (clbk) {

address = parameters().address || self.app.user.address.value

monetizationParameters.startPeriod = self.app.monetization.start
self.sdk.users.get(address, function(){

monetizationOpportunity = self.app.platform.sdk.users.checkMonetizationOpportunity(self.app.user.address.value)

var data = {
period: selectedPeriod,
monetizationOpportunity
};
monetizationParameters.startPeriod = self.app.monetization.start

clbk(data);
monetizationOpportunity = self.app.platform.sdk.users.checkMonetizationOpportunity(address)

var data = {
period: selectedPeriod,
monetizationOpportunity,
my : address == self.app.user.address.value
};

clbk(data);

})

},

Expand Down
82 changes: 82 additions & 0 deletions components/earnings/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,75 @@
@import "../../css/__cssvar";

#earnings {

.monetizationChange{
padding-top: 2 * @rhythm;
.exchangesProfiles{
display: flex;
padding : 2 * @rhythm;

}

.exchange{
padding: @rhythm;
background: rgba(var(--background-main),0.5);
max-width: 300px;
margin-right: @rhythm;
opacity: 0;
.transition(0.3s);

&.loaded{
opacity: 1;
}

#channel{

.channel{
position: relative;
background: transparent;

.icon{
position: absolute;
right: 0;
top : 0;
.usericon{
width: 22px;
height: 22px;
line-height: 22px;
}

}

.usericon{
margin-left: 0;
}

.userinfo{
flex-flow: column;

.openprofilebutton{
min-width: 0;
}
}
}


}

.panel{
[menuitem="posts"],
[menuitem="followers"],
[menuitem="following"]{
display: none;
}

}

.blockWrapper{
display: none;
}
}
}
.monetizationEnablePreview{
text-align: center;
padding : 4 * @rhythm;
Expand Down Expand Up @@ -555,6 +624,19 @@

.monetization{

.monetizationChange{
.exchangesProfiles{
display: flex;
flex-flow: column;
padding : 2 * @rhythm;
.exchange{
max-width: none;
margin-right: 0;
margin-bottom: 2 * @rhythm;
}
}
}

.disableMonetization{
margin-right: @rhythm;
}
Expand Down
2 changes: 2 additions & 0 deletions components/earnings/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</div>
<% } %>

<% if(my) {%>
<div class="work">
<div class="earnings">
<div class="top">
Expand All @@ -23,5 +24,6 @@
</div>
</div>
</div>
<% } %>

</div>
Loading

0 comments on commit 8e572d9

Please sign in to comment.