This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
Follow refactor #676
Merged
Merged
Follow refactor #676
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f49445a
initial code to fetch a followers / followings list on the user page
rmisio ab7ccd6
resurrected the ownFollowing collection
rmisio 86df33a
wip - updating own following list as you follow / unfollow users
rmisio 9cbeb6e
wip - fun with counts
rmisio 7231c1c
lazy loading in addition followers upon scrolling
rmisio 6f30e49
tweaks to handling of follower counts
rmisio 565a0d7
fetching profiles in the user card with async and cached options
rmisio 5d4453c
improving the error message if a follow / unfollow fails
rmisio ed4aef2
based on followsme adjusting other nodes following count
rmisio 84b6330
removing outdated follows collection test
rmisio 6593a5d
bumped up the number of followers per page
rmisio d349ec5
Apply the same changes to the connected peers page.
jjeffryes 94ba714
Merge pull request #688 from OpenBazaar/patchConnectedPeers
rmisio 2700fea
code review tweaks
rmisio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
import { Collection } from 'backbone'; | ||
import UserShort from '../models/UserCard'; | ||
/* Used for lists of followers and following */ | ||
|
||
import app from '../app'; | ||
import { Collection } from 'backbone'; | ||
import Follower from '../models/Follower'; | ||
|
||
export default class extends Collection { | ||
constructor(models = [], options = {}) { | ||
super(models, options); | ||
|
||
module.exports = Collection.extend({ | ||
/* we have to use the older style for this collection, the ES6 style creates a bug where models | ||
cannot be removed using their ids */ | ||
const types = ['followers', 'following']; | ||
if (types.indexOf(options.type) === -1) { | ||
throw new Error(`Please provide a type as one of ${types.join(', ')}`); | ||
} | ||
|
||
initialize(models, options) { | ||
if (!options.type) { | ||
throw new Error('You must provide a type to the collection'); | ||
if (!options.peerId) { | ||
throw new Error('Please provide a peerId'); | ||
} | ||
|
||
this.guid = options.guid; | ||
this.type = options.type; | ||
}, | ||
this.options = options; | ||
} | ||
|
||
url() { | ||
return app.getServerUrl(this.guid === app.profile.id || !this.guid ? | ||
`ob/${this.type}` : `ipns/${this.guid}/${this.type}`); | ||
}, | ||
model(attrs, options) { | ||
return new Follower(attrs, options); | ||
} | ||
|
||
modelId(attrs) { | ||
return attrs.peerId; | ||
} | ||
|
||
model: UserShort, | ||
url() { | ||
return app.getServerUrl(`ob/${this.options.type === 'followers' ? 'followers' : 'following'}` + | ||
`${app.profile.id === this.options.peerId ? '' : `/${this.options.peerId}`}`); | ||
} | ||
|
||
parse(response) { | ||
return response.map((guid) => { | ||
// if a plain guid was passed in, convert it to an object | ||
if (typeof guid === 'string') return { guid }; | ||
return guid; | ||
}); | ||
}, | ||
}); | ||
return response.map(peerId => ({ peerId })); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/* Used as a list item of both follower and following lists */ | ||
|
||
import BaseModel from './BaseModel'; | ||
|
||
export default class extends BaseModel { | ||
// this model will only be { guid: exampleguid } | ||
|
||
get idAttribute() { | ||
return 'guid'; | ||
return 'peerId'; | ||
} | ||
} | ||
|
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,2 @@ | ||
<div class="js-userCardsContainer userCardsContainer flexRow"></div> | ||
<div class="js-followLoadingContainer followLoadingContainer"></div> |
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,13 @@ | ||
<% if (ob.isFetching) { %> | ||
<div class="loadingSpinnerWrap"> | ||
<% print(ob.spinner({ className: 'spinnerMd' })) %> | ||
</div> | ||
<% } else if (ob.fetchFailed) { %> | ||
<p><%= ob.fetchErrorTitle %></p> | ||
<% if (ob.fetchErrorMsg) { %> | ||
<p><%= ob.fetchErrorMsg %></p> | ||
<% } %> | ||
<button class="btn normalBtn clrP clrBr js-retry"><%= ob.polyT('userPage.followTab.btnRetry') %></button> | ||
<% } else if (ob.noResults) { %> | ||
<p><%= ob.noResultsMsg %></p> | ||
<% } %> |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to use the cached profiles after all. The latency improvement is substantial. And... even having the freshest moderator info doesn't really solve the issue. After a mod is added, whether it's 1 minute, 1 hour or 6 months later, that mod can change their terms and the users using that mod would have no idea. Perhaps it's as simple as sending a notification to users of a mod if the mod changes their terms? Seems like a bigger UX discussion we could circle back to.