Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

notifications #888

Merged
merged 58 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2cb2cd9
Get the numberOfReplies from multiple sources
dapplion Dec 1, 2018
22ee080
Only show reputation for hashtags shown=true
dapplion Dec 1, 2018
ec0f3ae
Notifications skeleton
xardass Dec 6, 2018
40b214b
account create & restore visual
xardass Dec 6, 2018
3e3b99c
All notification views
xardass Dec 8, 2018
fdacd30
My keys fix
xardass Dec 8, 2018
8f5d61a
WIP
xardass Dec 8, 2018
20bfb51
fixed txHistory
xardass Dec 12, 2018
c539b0e
Notification rework
xardass Dec 12, 2018
63f900e
Notifications-counter
xardass Dec 12, 2018
8e73476
Counter reads from state value
xardass Dec 12, 2018
9b122ef
updating replycount
xardass Dec 12, 2018
b4980c7
Maintainer reputation
xardass Dec 12, 2018
244b12a
margins
xardass Dec 12, 2018
ba93f1e
Cleaner
xardass Dec 12, 2018
fe690fc
Fixes
xardass Dec 13, 2018
478f646
Added notifications saga
dapplion Dec 14, 2018
ae85eb4
Merge branch 'Epic30_notifications' into notifications_on_saga
xardass Dec 14, 2018
ed536e4
show 'item-replied' notification only if you are the seeker
dapplion Dec 15, 2018
9f179d1
Load notifications from localStorage
dapplion Dec 15, 2018
68d961e
Fix getItemMetadata type + lint code
dapplion Dec 15, 2018
0a06a85
Notifications styling
xardass Dec 16, 2018
aa7f1c3
show notifications
xardass Dec 16, 2018
19bd649
Add involved items subscription
dapplion Dec 16, 2018
23b4718
Merge remote-tracking branch 'origin/notifications_on_saga' into noti…
dapplion Dec 16, 2018
981873e
READ_NOTIFICATIONS redux action
dapplion Dec 16, 2018
629bea6
READ_NOTIFICATIONS typo
dapplion Dec 16, 2018
9fc0fe2
Add READ_NOTIFICATION to read only 1 notification
dapplion Dec 16, 2018
463afda
Fix itemHash typo
dapplion Dec 16, 2018
90d2c9f
Check if hashtagAddress is defined on item subscription
dapplion Dec 16, 2018
f9774ec
progress notifications
dapplion Dec 18, 2018
669e223
Checksums, variables..
xardass Dec 23, 2018
e14f61e
lowercase
xardass Dec 23, 2018
f880f9a
to lowerCase
dapplion Dec 23, 2018
5bf23cb
Merge remote-tracking branch 'origin/notifications_on_saga' into noti…
dapplion Dec 23, 2018
67fa8f4
notifications middleware
dapplion Dec 27, 2018
f35b029
Notifications ordering, balance updates & lowercase address checks
xardass Dec 31, 2018
47c61ff
Unnecessary console
xardass Dec 31, 2018
80b4c5a
don't update balance continously
dapplion Jan 5, 2019
73121b3
Merge remote-tracking branch 'origin/notifications_on_saga' into noti…
dapplion Jan 5, 2019
c6af7de
Improve notifications selector
dapplion Jan 5, 2019
bdfdbed
Send hashtagAddress to the api on chat creation
dapplion Jan 5, 2019
22178db
Store fallback info in the notification
dapplion Jan 5, 2019
a1b1c06
Add balance-received notification
dapplion Jan 5, 2019
c750779
trigger balance-received only on kovan
dapplion Jan 5, 2019
c6bfebc
guard against empty array
dapplion Jan 5, 2019
ec66285
Mark all read
xardass Jan 10, 2019
0e4dcff
Work on notifications-count
xardass Jan 10, 2019
3e0a342
Merge branch '#884_cosmetics3_fonts' into notifications_on_saga
xardass Jan 15, 2019
5723f01
Read notification
xardass Jan 15, 2019
dae730a
Archive
xardass Jan 17, 2019
3027f87
Create item & notification fixes
xardass Jan 19, 2019
7d06e0f
Delete by id
xardass Jan 20, 2019
2a5bdaa
Import path
xardass Jan 20, 2019
415a237
Fix notification saga typos
dapplion Jan 21, 2019
d2895ab
Merge remote-tracking branch 'origin/notifications_on_saga' into noti…
dapplion Jan 21, 2019
db2c0a9
Merge remote-tracking branch 'origin/notifications_on_saga' into Read…
xardass Jan 21, 2019
a858c6a
Merge branch 'master' into Read_notification
xardass Jan 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bower_components/**
build/**
webpack/**
src/redux/**
test/**
213 changes: 155 additions & 58 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"eslint-plugin-html": "^4.0.5",
"ethereumjs-tx": "^1.3.7",
"ethereumjs-util": "^5.2.0",
"mocha": "^5.2.0",
"moment": "^2.22.2",
"polymer-cli": "^1.8.0",
"qrcode": "^1.2.2",
Expand All @@ -28,6 +29,7 @@
"lint": "npm run lint:javascript",
"lint:javascript": "eslint . --ext js,html --ignore-path .eslintignore",
"test": "polymer test",
"mocha": "mocha \"test/**/*.test.js\"",
"test:integration": "polymer build # test that psk builds without error with the CLI",
"build": "npm install && npm run webpack && node --max-old-space-size=8192 ./node_modules/.bin/polymer build",
"build:nowp": "node --max-old-space-size=8192 ./node_modules/.bin/polymer build --verbose",
Expand Down
45 changes: 45 additions & 0 deletions src/data/data-notifications.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--
@license
Copyright (c) 2018 Swarm City
This code may only be used under the license found at https://github.com/swarmcity/license
-->
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="./socket-redux.html" />
<link rel="import" href="../redux-state.html">

<!-- This component will catch all events that send out notifications and act on those events -->

<dom-module id="data-notifications">

<template>
<socket-redux id="socket"></socket-redux>
</template>
<script>
class DataNotifications extends new ReduxMixin(Polymer.Element) {
static get is() {
return 'data-notifications';
}
static get properties() {
return {
notifications: {
type: Object,
statePath: AppStore.selectors.notifications,
},
};
}


ready() {
super.ready();
window.addEventListener('newItem', function () {

console.log('new item noticed in data-notifications')

}.bind(this), false);
}


}
window.customElements.define(DataNotifications.is, DataNotifications);
</script>
</dom-module>
97 changes: 9 additions & 88 deletions src/data/socket-redux.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,51 +57,6 @@
nonce: {
type: Number,
},
/**
* This is the shortCode we want a public key for
* as given by the ETH network
* @type {Number}
*/
reqtokey: {
type: Number,
statePath: 'reqtokey',
observer: '_reqToKey',
},
/**
* Historic transactions for publickey
* @type {Array}
*/
transactions: {
type: Array,
statePath: 'transactions',
},
/**
* Get base 64 image from IPFS hash
* @type {Array}
*/
reqipfs: {
type: String,
statePath: 'reqipfs',
observer: '_reqipfs',
},
/**
* An ipfs hash we want to resolve over the API
* @type {Array}
*/
ipfsHash: {
type: String,
statePath: 'ipfsHash',
observer: '_ipfsHashResolve',
},
/**
* Send new request metadata to IPFS
* @type {Object}
*/
itemToIpfs: {
type: Object,
statePath: 'itemToIpfs',
observer: '_itemToIpfs',
},
/**
* Send new signed tx to the blockchain
* @type {Object}
Expand All @@ -119,27 +74,6 @@
type: Array,
statePath: 'confirmedTx',
},
/**
* An Object containing the data for a hashtagItem
* @type {Object}
*/
hashtagItem: {
type: Object,
statePath: 'hashtagItem',
},
/**
* The selected user's reputation balance
* @type {Object}
*/
userReputation: {
type: Object,
statePath: 'userReputation',
observer: '_getUserReputation',
},
chats: {
type: Object,
statePath: AppStore.selectors.chats,
},
};
}
/**
Expand Down Expand Up @@ -227,12 +161,8 @@
this._subscribeToChat({
itemHash,
})
.then(() => {
console.log('Successfully joined chat channel for item: ', itemHash)
})
.catch(err => {
console.log('Error instantiating chat channel:', err)
});
.then(() => console.log('Successfully joined chat channel for item: ', { itemHash }))
.catch(e => console.error(`Error instantiating chat channel for itemHash ${itemHash}: ${e.stack}`));
}.bind(this), false);
}

Expand Down Expand Up @@ -302,25 +232,16 @@
});
})
}
// Get a certain user's reputation balance by address
_getUserReputation() {
if (this.userReputation.request) {
this.socket.emit('getReputation', {
address: this.userReputation.request,
}, (reply) => {
this.dispatch({
type: 'USERREPUTATION',
userReputation: reply.data
});
});
}
}

_subscribeToChat({ accessKeys, itemHash}) {
_subscribeToChat({ accessKeys, itemHash, hashtagAddress }) {
return new Promise((resolve, reject) => {
// Store hashtagAddress in the db's chatObject to latter know
// which hashtag this item belongs to
const info = hashtagAddress ? { hashtagAddress } : {}
this.socket.emit('subscribeToChat', {
accessKeys,
itemHash
accessKeys,
itemHash,
info
}, (reply) => {
if (reply.response == 200) {
resolve(reply.data);
Expand Down
80 changes: 80 additions & 0 deletions src/displays/display-button-text.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--
@license
Copyright (c) 2018 Swarm City
This code may only be used under the license found at https://github.com/swarmcity/license
-->
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/app-localize-behavior/app-localize-behavior.html">
<link rel="import" href="../../bower_components/iron-media-query/iron-media-query.html">
<!--

Example:
```
<display-button-text></display-button-text>
```

### Styling

Style the button with CSS as you would a normal DOM element.

The following custom properties and mixins are available for styling:

| Custom property | Description | Default |
| --- | --- | --- |
| `--display-button-text` | Mixin applied to the deal button | `{}` |
-->
<dom-module id="display-button-text">
<template>
<style include="shared-styles">
:host {
display: block;
}

.button {
@apply --small-light;
color: var(--sc-grey4);
width: 115px;
height: 40px;
box-sizing: border-box;
padding: 10px;
cursor: pointer;
@apply --layout-vertical;
@apply --layout-center-center;
box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.35);
-webkit-box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.35);
-moz-box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.35);
-o-box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.35);
}

.container[wide-layout] .button {
box-shadow: 0px 1px 2px -1px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0px 1px 2px -1px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0px 1px 2px -1px rgba(0, 0, 0, 0.5);
-o-box-shadow: 0px 1px 2px -1px rgba(0, 0, 0, 0.5);
}

.button:active {
@apply --button-active;
}
</style>
<iron-media-query query="(min-width: 600px)" query-matches="{{wide}}"></iron-media-query>
<div class="container" wide-layout$="{{wide}}">
<div class="button">
[[label]]
</div>
</div>

</template>
<script>
class MyDisplayButtonText extends new ReduxMixin(Polymer.mixinBehaviors([
Polymer.AppLocalizeBehavior,
],
Polymer.Element
)) {
static get is() {
return 'display-button-text';
}
}
window.customElements.define(MyDisplayButtonText.is, MyDisplayButtonText);
</script>
</dom-module>
35 changes: 34 additions & 1 deletion src/displays/display-my-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@
background-color: var(--sc-yellow);
opacity: 0.6;
}

.notificationsCount {
color: var(--sc-white);
border-radius: 50%;
@apply --small-bold;
@apply --layout-vertical;
@apply --layout-center-center;
text-align: center;
height: 24px;
width: 24px;
min-width: 24px;
background-color: var(--sc-grey4);
margin: 18px 0 0 -8px;
z-index: 99;
}

.container[wide-layout] .notificationsCount {
margin: 25px 0 0 -8px;
}
</style>

<app-location route="{{route}}"></app-location>
Expand All @@ -157,7 +176,9 @@

<dom-if if="{{publicKey}}">
<template>
<iron-image id="image" sizing="cover" on-click="_toProfile" preload src="https://scapiweb3-c.swarm.city/img/[[avatarHash]]" placeholder="../images/defaultavatar.png"></iron-image>
<iron-image id="image" sizing="cover" on-click="_toProfile" preload src="https://scapiweb3-c.swarm.city/img/[[avatarHash]]"
placeholder="../images/defaultavatar.png"></iron-image>
<div class="notificationsCount" on-tap="_toNotifications">[[notificationsCount]]</div>
<div class="totalbox">
<div id="username" on-click="_toProfile">{{ username }}</div>
<div id="balance" on-click="_toWallet">
Expand Down Expand Up @@ -216,6 +237,14 @@
type: String,
statePath: AppStore.selectors.avatarHash
},
/**
* Avatar represents the user's base64 of their avatar image
* @type {String}
*/
notificationsCount: {
type: String,
statePath: AppStore.selectors.notificationsCount
},
/**
* Balance represents the users SWT balance
* @type {Number}
Expand Down Expand Up @@ -275,6 +304,10 @@
}
}

_toNotifications() {
this.dispatchEvent(new CustomEvent("notifications"));
}

/**
* takes the user to the my-wallet page
*/
Expand Down
Loading