This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #875 from swarmcity/S01E05-live
Resolve
- Loading branch information
Showing
23 changed files
with
802 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!-- | ||
@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" /> | ||
|
||
<!-- Displays and shared styles only --> | ||
<link rel="import" href="../../shared-styles.html" /> | ||
|
||
<dom-module id="chat-conflict-resolve"> | ||
<template> | ||
<style include="shared-styles"> | ||
:host { | ||
display: block; | ||
} | ||
|
||
.container { | ||
margin-top: 20px; | ||
} | ||
|
||
.date { | ||
@apply --layout-horizontal; | ||
@apply --layout-center-justified; | ||
@apply --smallest-light; | ||
color: var(--sc-grey3b); | ||
} | ||
|
||
.text { | ||
@apply --layout-horizontal; | ||
@apply --layout-center-justified; | ||
@apply --small-light; | ||
margin: 5px 0 10px 0; | ||
padding: 10px 20px; | ||
box-sizing: border-box; | ||
text-align: center; | ||
background-color: var(--sc-grey1b); | ||
} | ||
|
||
.red { | ||
color: var(--sc-red); | ||
} | ||
</style> | ||
<div class="container"> | ||
<div class="date">[[_formatDate(message.time)]]</div> | ||
<div class="text"> | ||
The conflict is resolved by the hashtag maintainer. | ||
[[item.seekerUsername]] has been paid [[_seekerPayout(item.itemValue, message)]] SWT | ||
and [[_getProviderUsername(item)]] has been paid [[_providerPayout(item.itemValue, message)]] SWT. | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
class MyChatConflictResolve extends (new ReduxMixin( | ||
Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior], Polymer.Element) | ||
)) { | ||
static get is() { | ||
return "chat-conflict-resolve"; | ||
} | ||
static get properties() { | ||
return { | ||
message: Object, | ||
item: Object, | ||
}; | ||
} | ||
|
||
/** | ||
* formats epoch | ||
* @param {DateTime} dateTime epoch in javascript milliseconds | ||
* @return {string} formatted date string | ||
*/ | ||
_formatDate(dateTime) { | ||
let milliseconds = dateTime * 1000; | ||
if (webpack.moment().valueOf() - milliseconds < 86400000) { | ||
return webpack.moment(milliseconds).fromNow(); | ||
} else { | ||
return webpack.moment(milliseconds).format("DD MMM YYYY - HH:mm"); | ||
} | ||
} | ||
_seekerPayout(wei, message) { | ||
if (message && message.seekerPercentage) return ((wei * message.seekerPercentage) / 1e18).toFixed(2); | ||
if (message && message.message.seekerPercentage) return ((wei * message.seekerPercentage) / 1e18).toFixed(2); | ||
|
||
} | ||
|
||
_providerPayout(wei, message) { | ||
if (message && message.seekerPercentage) return ((wei - (wei * message.seekerPercentage)) / 1e18).toFixed(2); | ||
if (message && message.message.seekerPercentage) return ((wei - (wei * message.seekerPercentage)) / 1e18).toFixed(2); | ||
|
||
} | ||
_getProviderUsername(item) { | ||
if (item && item.replies) { | ||
return item.replies[item.providerAddress].username | ||
} | ||
} | ||
} | ||
window.customElements.define(MyChatConflictResolve.is, MyChatConflictResolve); | ||
</script> | ||
</dom-module> |
Oops, something went wrong.