Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/modules/app/services/DefaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
lastOpenVersion: '',
whatsNewList: [],
closedNotification: [],
dontShowSpam: true,
withScam: false,
scamListUrl: WavesApp.network.scamListUrl,
logoutAfterMin: 5,
Expand Down
19 changes: 18 additions & 1 deletion src/modules/app/services/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
(function () {
'use strict';

const { equals } = require('ramda');

/* global
Mousetrap
*/
Expand All @@ -11,6 +13,7 @@
'extraFee',
'networkError',
'changeScript',
'setScamSignal',
'scam'
];

Expand Down Expand Up @@ -104,6 +107,10 @@
* @type {Signal<void>}
*/
changeScript = new tsUtils.Signal();
/**
* @type {Signal<void>}
*/
setScamSignal = new tsUtils.Signal();
/**
* @type {Record<string, boolean>}
*/
Expand Down Expand Up @@ -174,7 +181,16 @@
setTimeout(() => {
this._scriptInfoPoll = new Poll(() => this.updateScriptAccountData(), () => null, 10000);
}, 30000);

});

}

setScam(hash) {
if (!equals(hash, this.scam)) {
this.scam = hash;
this.setScamSignal.dispatch();
}
}

/**
Expand Down Expand Up @@ -341,7 +357,8 @@
hasBackup,
lng: i18next.language,
theme: themes.getDefaultTheme(),
candle: 'blue'
candle: 'blue',
dontShowSpam: true
}
}).then(() => {
if (restore) {
Expand Down
19 changes: 9 additions & 10 deletions src/modules/app/services/waves/node/content/Assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
'use strict';

const entities = require('@waves/data-entities');
const { equals } = require('ramda');

/**
* @param {BaseNodeComponent} BaseNodeComponent
Expand All @@ -21,9 +20,10 @@
constructor() {
super();
user.onLogin().then(() => {

if (!user.getSetting('withScam')) {
if (user.getSetting('scamListUrl')) {
this.stopScam();
} else {
this.giveMyScamBack();
}
});
}
Expand Down Expand Up @@ -133,9 +133,9 @@
}

stopScam() {
if (this._pollScam) {
return null;
}
// if (this._pollScam) {
// return null;
// }
/**
* @type {Poll}
* @private
Expand All @@ -158,17 +158,16 @@
}
});
return hash;
});
})
.catch(() => Object.create(null));
}

/**
* @param hash
* @private
*/
_setScamAssetList(hash) {
if (!equals(hash, user.scam)) {
user.scam = hash;
}
user.setScam(hash);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/modules/ui/directives/actions/actions.less
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ w-actions {
height: 4px;
border-radius: 100%;
background-color: @color-basic-500;

.spam & {
background-color: @color-basic-200;
}
}
}

Expand Down
15 changes: 13 additions & 2 deletions src/modules/ui/directives/transaction/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@
* @param {INotification} notification
* @param {Waves} waves
* @param {User} user
* @param {$rootScope.Scope} $scope
* @return {Transaction}
*/
const controller = function (Base, $filter, modalManager, notification,
waves, user) {
waves, user, $scope) {

const { SIGN_TYPE } = require('@waves/signature-adapter');
class Transaction extends Base {

$postLink() {
this.typeName = this.transaction.typeName;
this.setScam();

this.receive(user.setScamSignal, () => {
this.setScam();
$scope.$apply();
});
}

setScam() {
this.isScam = !!user.scam[this.transaction.assetId];
if (this.transaction.type === 7) {
const isScamAmount = !!user.scam[this.transaction.amount.asset];
Expand Down Expand Up @@ -115,7 +125,8 @@
'modalManager',
'notification',
'waves',
'user'
'user',
'$scope'
];

angular.module('app.ui')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
isScam: this.isScam
};

// TODO: delete setTimeout
setTimeout(() => {
this.props.isScam = this.isScam;
}, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
this.isScam = this.props.isScam;
}, 0);

// TODO: delete setTimeout
setTimeout(() => {
this.isScam = this.props.isScam;
}, 0);

const TYPES = waves.node.transactions.TYPES;

switch (this.typeName) {
Expand Down
26 changes: 24 additions & 2 deletions src/modules/ui/directives/transactionList/TransactionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@
* @type {boolean}
*/
this.pending = false;
/**
* @type {boolean}
*/
this.dontShowSpam = user.getSetting('dontShowSpam');

this.syncSettings({
dontShowSpam: 'dontShowSpam'
});

this.observe('_transactions', this._onChangeTransactions);
this.observe(['_transactions', 'dontShowSpam'], this._onChangeTransactions);
}

$postLink() {
Expand All @@ -39,7 +47,11 @@
* @private
*/
_onChangeTransactions() {
const transactions = (this._transactions || []);
let transactions = (this._transactions || []);
if (this.dontShowSpam) {
transactions = transactions.filter(this._filterSpam);
}

const hash = Object.create(null);
const toDate = tsUtils.date('DD.MM.YYYY');

Expand All @@ -61,6 +73,16 @@
}));
}

_filterSpam(transaction) {
const isScam = !!user.scam[transaction.assetId];
let isScamAmount, isScamPrice;
if (transaction.type === 7) {
isScamAmount = !!user.scam[transaction.amount.asset];
isScamPrice = !!user.scam[transaction.price.asset];
}
return !(isScam || isScamAmount || isScamPrice);
}

}

return new TransactionList();
Expand Down
7 changes: 6 additions & 1 deletion src/modules/utils/modals/pinAsset/PinAssetCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const R = require('ramda');
* @type {boolean}
*/
this.withScam = null;
/**
* @type {boolean}
*/
this.dontShowSpam = null;
/**
* @type {Array<Asset>}
*/
Expand All @@ -52,7 +56,8 @@ const R = require('ramda');
this.syncSettings({
pinnedAssetIdList: 'pinnedAssetIdList',
spam: 'wallet.portfolio.spam',
withScam: 'withScam'
withScam: 'withScam',
dontShowSpam: 'dontShowSpam'
});

this.observe('search', this._fillList);
Expand Down
24 changes: 14 additions & 10 deletions src/modules/utils/modals/settings/SettingsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
matcher = '';
api = '';
scamListUrl = '';
withScam = false;
dontShowSpam = true;
theme = user.getSetting('theme');
candle = user.getSetting('candle');
templatePromise = $templateRequest('modules/utils/modals/settings/loader.html');
Expand Down Expand Up @@ -100,10 +100,11 @@
api: 'network.api',
logoutAfterMin: 'logoutAfterMin',
scamListUrl: 'scamListUrl',
withScam: 'withScam',
dontShowSpam: 'dontShowSpam',
theme: 'theme',
candle: 'candle',
oracleWaves: 'oracleWaves'

});

this.assetsOracleTmp = this.oracleWaves;
Expand Down Expand Up @@ -158,13 +159,16 @@
// user.changeCandle(this.candle);
// });

this.observe('withScam', () => {
const withScam = this.withScam;
if (withScam) {
waves.node.assets.giveMyScamBack();
} else {
waves.node.assets.stopScam();
}
this.observe('dontShowSpam', () => {
const dontShowSpam = this.dontShowSpam;
user.setSetting('dontShowSpam', dontShowSpam);
});

this.observe('scamListUrl', () => {
ds.config.setConfig({
scamListUrl: this.scamListUrl
});
waves.node.assets.stopScam();
});

this.observe(['node', 'matcher', 'api'], () => {
Expand Down Expand Up @@ -216,7 +220,7 @@
setNetworkDefault() {
this.node = WavesApp.network.node;
this.matcher = WavesApp.network.matcher;
this.withScam = false;
this.dontShowSpam = true;
this.scamListUrl = WavesApp.network.scamListUrl;
this.oracleWaves = WavesApp.oracles.waves;
this.api = WavesApp.network.api;
Expand Down
5 changes: 3 additions & 2 deletions src/modules/utils/modals/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,15 @@
<w-input ng-model="$ctrl.scamListUrl"></w-input>
<w-help-icon class="info">
<div class="help-icon__row headline-3" w-i18n="modal.settings.network.spamListHelp"></div>
<div class="help-icon__row" w-i18n="modal.settings.network.forDisableClear"></div>
</w-help-icon>
</div>
</div>

<div class="margin-3 margin-top-2">
<div class="row flex-row row-style unit-checkbox">
<w-checkbox-submit id="spamFilterToggle" ng-model="$ctrl.withScam"></w-checkbox-submit>
<label for="spamFilterToggle" w-i18n="modal.settings.network.spamFilterInputDescr"></label>
<w-checkbox-submit id="spamFilterToggle" ng-model="$ctrl.dontShowSpam"></w-checkbox-submit>
<label for="spamFilterToggle" w-i18n="modal.settings.network.dontShowSpamCheckboxDescr"></label>
</div>
</div>

Expand Down
27 changes: 20 additions & 7 deletions src/modules/wallet/modules/portfolio/controllers/PortfolioCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
* @type {boolean}
*/
this.pending = true;
/**
* @type {boolean}
*/
this.dontShowSpam = user.getSetting('dontShowSpam');

waves.node.assets.getAsset(this.mirrorId)
.then((mirror) => {
Expand Down Expand Up @@ -132,7 +136,8 @@
this.syncSettings({
pinned: 'pinnedAssetIdList',
spam: 'wallet.portfolio.spam',
filter: 'wallet.portfolio.filter'
filter: 'wallet.portfolio.filter',
dontShowSpam: 'dontShowSpam'
});

balanceWatcher.ready
Expand All @@ -144,7 +149,7 @@

this.receive(balanceWatcher.change, onChange);
this.receive(utils.observe(user, 'scam'), onChange);
this.observe(['pinned', 'spam'], onChange);
this.observe(['pinned', 'spam', 'dontShowSpam'], onChange);

this._updateBalances();
});
Expand Down Expand Up @@ -310,16 +315,24 @@
})
.reduce((acc, item) => {
const oracleData = ds.dataManager.getOraclesAssetData(item.asset.id);
const spam = item.isOnScamList || item.isSpam;

if (item.asset.sender === user.address) {
acc.my.push(item);
}
if (oracleData && oracleData.status > 0) {
acc.verified.push(item);
}
if (item.isOnScamList || item.isSpam) {
acc.spam.push(item);

if (spam) {
if (!this.dontShowSpam) {
if (item.asset.sender === user.address) {
acc.my.push(item);
}
acc.spam.push(item);
acc.active.push(item);
}
} else {
if (item.asset.sender === user.address) {
acc.my.push(item);
}
acc.active.push(item);
}

Expand Down
Loading