diff --git a/src/js/Session.js b/src/js/Session.js index 1e0a6c48..da10ceb3 100644 --- a/src/js/Session.js +++ b/src/js/Session.js @@ -14,8 +14,8 @@ let myProfilePhoto; let latestChatLink; let onlineTimeout; let ourActivity; -let hasFollows; -let hasFollowers; +let noFollows; +let noFollowers; let userSearchIndex; const follows = {}; const channels = window.channels = {}; @@ -63,8 +63,8 @@ function addFollow(callback, k, followDistance, follower) { } callback && callback(k, follows[k]); updateUserSearchIndex(); - updateHasFollows(); - updateHasFollowers(); + updateNoFollows(); + updateNoFollowers(); } function removeFollow(k, followDistance, follower) { @@ -73,8 +73,8 @@ function removeFollow(k, followDistance, follower) { if (followDistance === 1) { State.local.get('groups').get('follows').get(k).put(false); } - updateHasFollows(); - updateHasFollowers(); + updateNoFollows(); + updateNoFollowers(); } } @@ -102,21 +102,21 @@ function getExtendedFollows(callback, k, maxDepth = 3, currentDepth = 1) { return follows; } -function updateHasFollows() { - const v = Object.keys(follows).length > 1; - if (v !== hasFollows) { - hasFollows = v; - State.local.get('hasFollows').put(hasFollows); +const updateNoFollows = _.debounce(() => { + const v = !(Object.keys(follows).length > 1); + if (v !== noFollows) { + noFollows = v; + State.local.get('noFollows').put(noFollows); } -} +}, 1000); -function updateHasFollowers() { - const v = follows[key.pub] && (follows[key.pub].followers.size > 0); - if (v !== hasFollowers) { - hasFollowers = v; - State.local.get('hasFollowers').put(hasFollowers); +const updateNoFollowers = _.debounce(() => { + const v = !(follows[key.pub] && (follows[key.pub].followers.size > 0)); + if (v !== noFollowers) { + noFollowers = v; + State.local.get('noFollowers').put(noFollowers); } -} +}, 1000); function getUserSearchIndex() { return userSearchIndex; @@ -165,7 +165,7 @@ function updateGroups() { } State.local.get('groups').get('everyone').get(k).put(true); if (k === getPubKey()) { - updateHasFollowers(); + updateNoFollowers(); } }); } diff --git a/src/js/components/SearchBox.js b/src/js/components/SearchBox.js index 6a5ce6fe..f627e7cc 100644 --- a/src/js/components/SearchBox.js +++ b/src/js/components/SearchBox.js @@ -32,7 +32,7 @@ class SearchBox extends Component { componentDidMount() { State.local.get('groups').get('everyone').map().on(this.sub( () => { - this.hasFollows = this.hasFollows || Object.keys(Session.getFollows()).length > 1; + this.noFollows = this.noFollows || Object.keys(Session.getFollows()).length > 1; } )); State.local.get('activeRoute').on(this.sub( @@ -147,7 +147,7 @@ class SearchBox extends Component { `; })} - ${this.state.query && !this.hasFollows ? html` + ${this.state.query && !this.noFollows ? html` Follow someone to see more search results! <${Identicon} str=${suggestedFollow} width=40/> diff --git a/src/js/views/Feed.js b/src/js/views/Feed.js index fe8e4c24..406eaa3b 100644 --- a/src/js/views/Feed.js +++ b/src/js/views/Feed.js @@ -67,7 +67,7 @@ class Feed extends View { ${s.searchTerm ? html`

Search results for "${s.searchTerm}"

` : html` ${this.getNotification()} `} - ${s.hasFollows ? html`<${Filters}/>` : ''} + ${!s.noFollows ? html`<${Filters}/>` : ''} <${MessageFeed} scrollElement=${this.scrollElement.current} hashtag=${hashtag} diff --git a/src/js/views/Profile.js b/src/js/views/Profile.js index 828aad2c..c4204024 100644 --- a/src/js/views/Profile.js +++ b/src/js/views/Profile.js @@ -58,7 +58,7 @@ class Profile extends View { } getNotification() { - if (!this.state.hasFollowers && this.followers.has(Session.getPubKey())) { + if (this.state.noFollowers && this.followers.has(Session.getPubKey())) { return html`
@@ -296,7 +296,7 @@ class Profile extends View { } let qrCodeEl = $(this.qrRef.current); qrCodeEl.empty(); - State.local.get('hasFollowers').on(this.inject()); + State.local.get('noFollowers').on(this.inject()); this.getProfileDetails(); if (chat) { $(`input[name=notificationPreference][value=${ chat.notificationSetting }]`).attr('checked', 'checked'); diff --git a/src/js/views/Store.js b/src/js/views/Store.js index cddcbfa7..51e508b8 100644 --- a/src/js/views/Store.js +++ b/src/js/views/Store.js @@ -92,7 +92,7 @@ class Store extends View { const cartTotalItems = Object.keys(this.cart).reduce((sum, k) => sum + this.cart[k], 0); const keys = Object.keys(this.state.items); return html` - ${(this.props.store || !this.state.hasFollows) ? '' : html`<${Filters}/>`} + ${(this.props.store || this.state.noFollows) ? '' : html`<${Filters}/>`} ${cartTotalItems ? html`

diff --git a/src/js/views/View.js b/src/js/views/View.js index b05384ac..aed63afe 100644 --- a/src/js/views/View.js +++ b/src/js/views/View.js @@ -27,11 +27,11 @@ class View extends Component { getNotification() { if (!this.followsSubscribed) { this.followsSubscribed = true; - State.local.get('hasFollowers').on(this.inject()); - State.local.get('hasFollows').on(this.inject()); + State.local.get('noFollowers').on(this.inject()); + State.local.get('noFollows').on(this.inject()); } - if (!this.state.hasFollows) { + if (this.state.noFollows) { return html`

@@ -48,7 +48,7 @@ class View extends Component {
` } - if (!this.state.hasFollowers) { + if (this.state.noFollowers) { return html`