Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace followers list with friends list #1881

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/ui/menu/menuView.tsx
Expand Up @@ -96,10 +96,6 @@ function renderProfileActions(user: Session) {
<span data-icon="f" />
{plural('nbFriendsOnline', friendsApi.count())}
</li>
<li className="side_link" data-route={`/@/${user.id}/related`}>
<span className="fa fa-arrow-circle-left" />
{plural('nbFollowers', user.nbFollowers || 0)}
</li>
<li className="side_link" data-nocloseaction="logout">
<span data-icon="w" />
{i18n('logOut')}
Expand Down
8 changes: 1 addition & 7 deletions src/ui/user/related/RelatedCtrl.ts
Expand Up @@ -62,13 +62,7 @@ export default class RelatedCtrl {
}

private getData(userId: string, page: number): Promise<void> {
return this.currentTab === 0 ?
xhr.followers(userId, page)
.then(d => {
this.followers = (this.followers || []).concat(d.paginator.currentPageResults)
this.followersPaginator = d.paginator
}) :
xhr.following(userId, page)
return xhr.following(userId, page)
.then(d => {
this.following = (this.following || []).concat(d.paginator.currentPageResults)
this.followingPaginator = d.paginator
Expand Down
13 changes: 6 additions & 7 deletions src/ui/user/related/related.ts
Expand Up @@ -8,6 +8,8 @@ import { dropShadowHeader, backButton } from '../../shared/common'
import RelatedCtrl from './RelatedCtrl'
import { renderBody } from './relatedView'

import i18n from '../../../i18n'

interface Attrs {
id: string
tab?: string
Expand All @@ -28,13 +30,10 @@ export default {
safeStringToNum(vnode.attrs.tab)
)
},
view({ attrs }) {
const name = attrs.username ? h('div.title', [
h('span', [
...(attrs.title ? [h('span.userTitle', attrs.title), ' '] : []),
attrs.username
])
]) : attrs.id
view() {
const name = h('div.title', [
h('span', i18n('friends'))
])

return layout.free(
dropShadowHeader(null, backButton(name)),
Expand Down
32 changes: 15 additions & 17 deletions src/ui/user/related/relatedView.tsx
@@ -1,36 +1,21 @@
import h from 'mithril/hyperscript'
import router from '../../../router'
import { gameIcon } from '../../../utils'
import i18n, { plural } from '../../../i18n'
import i18n from '../../../i18n'
import spinner from '../../../spinner'
import { Related } from '../../../lichess/interfaces/user'
import { Paginator } from '../../../lichess/interfaces'
import * as helper from '../../helper'
import TabNavigation from '../../shared/TabNavigation'
import TabView from '../../shared/TabView'

import challengeForm from '../../challengeForm'
import RelatedCtrl from './RelatedCtrl'

export function renderBody(ctrl: RelatedCtrl) {
const tabsContent = [
{ id: 'followers', f: () => renderContent(ctrl, ctrl.followers, ctrl.followersPaginator) },
{ id: 'following', f: () => renderContent(ctrl, ctrl.following, ctrl.followingPaginator) },
]

const nbFollowers = ctrl.followersPaginator && ctrl.followersPaginator.nbResults
const nbFollowing = ctrl.followingPaginator && ctrl.followingPaginator.nbResults

return [
h('div.tabs-nav-header.subHeader',
h(TabNavigation, {
buttons: [
{ label: plural('nbFollowers', nbFollowers || 0, nbFollowers ? undefined : '') },
{ label: plural('nbFollowing', nbFollowing || 0, nbFollowing ? undefined : '') },
],
selectedIndex: ctrl.currentTab,
onTabChange: ctrl.onTabChange
}),
),
h(TabView, {
selectedIndex: ctrl.currentTab,
tabs: tabsContent,
Expand Down Expand Up @@ -98,6 +83,19 @@ function renderPlayer(ctrl: RelatedCtrl, obj: Related, i: number) {
{perf.rating}
</span> : null
}
<div className="buttons">
<span data-icon="U" oncreate={helper.ontapY((e: Event) => {
e.stopPropagation()
close()
challengeForm.open(obj.user)
})} />
<span>{' '}</span>
<span data-icon="c" oncreate={helper.ontapY((e: Event) => {
e.stopPropagation()
close()
router.set(`/inbox/new/${obj.user}`)
})} />
</div>
</div>
{obj.followable ?
<div className="followingPlayerItem">
Expand Down
2 changes: 1 addition & 1 deletion src/ui/user/userView.tsx
Expand Up @@ -248,7 +248,7 @@ function renderActions(ctrl: IUserCtrl, user: ProfileUser) {
<div className="list_item nav"
oncreate={helper.ontapY(ctrl.followers)}
>
{plural('nbFollowers', user.nbFollowers)}
{i18n('friends')}
</div>
{ !ctrl.isMe() ? <div className="list_item nav" data-icon="1"
oncreate={helper.ontapY(ctrl.goToUserTV)}
Expand Down