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

Release #702

Merged
merged 4 commits into from
Nov 14, 2020
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
9 changes: 9 additions & 0 deletions app/API/graphql_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ export const loggedInUserUnreadNotificationsCount = gql`
}
}
`

export const loggedInUserPendingModerationCount = gql`
query LoggedInUserUnreadNotificationsCount {
loggedInUser {
id
actions_pending_moderation
}
}
`
22 changes: 19 additions & 3 deletions app/components/App/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { Query } from 'react-apollo'
import { withNamespaces } from 'react-i18next'
import classNames from 'classnames'
import { get } from 'lodash'
import capitalize from 'voca/capitalize'
import { Flex } from '@rebass/grid'

Expand All @@ -15,12 +17,14 @@ import { Facebook } from 'styled-icons/fa-brands/Facebook'

import { LinkExternal } from 'styled-icons/octicons/LinkExternal'

import { loggedInUserPendingModerationCount } from '../../API/graphql_queries'
import { MOBILE_WIDTH_THRESHOLD, MIN_REPUTATION_MODERATION } from '../../constants'
import RawIcon from '../Utils/RawIcon'
import ReputationGuard from '../Utils/ReputationGuard'
import { closeSidebar, toggleSidebar } from '../../state/user_preferences/reducer'
import UserLanguageSelector from '../LoggedInUser/UserLanguageSelector'
import ExternalLinkNewTab from '../Utils/ExternalLinkNewTab'
import Tag from '../Utils/Tag'

@connect((state) => ({ sidebarExpended: state.UserPreferences.sidebarExpended }), {
toggleSidebar,
Expand Down Expand Up @@ -142,9 +146,21 @@ export default class Sidebar extends React.PureComponent {
{capitalize(t('entities.video_plural'))}
</this.MenuListLink>
<ReputationGuard requiredRep={MIN_REPUTATION_MODERATION}>
<this.MenuListLink to="/moderation" iconName="flag">
{t('menu.moderation')}
</this.MenuListLink>
<Query
fetchPolicy="network-only"
pollInterval={25000}
query={loggedInUserPendingModerationCount}
>
{({ data }) => {
const pendingCount = get(data, 'loggedInUser.actions_pending_moderation', 0)
return (
<this.MenuListLink to="/moderation" iconName="flag">
{t('menu.moderation')}
<Tag type="danger">{pendingCount}</Tag>
</this.MenuListLink>
)
}}
</Query>
</ReputationGuard>
</ul>
)
Expand Down
3 changes: 2 additions & 1 deletion app/components/VideoDebate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { resetVideoDebate } from '../../state/video_debate/actions'
import { ColumnVideo } from './ColumnVideo'
import { ColumnDebate } from './ColumnDebate'
import { videoURL, toAbsoluteURL } from '../../lib/cf_routes'
import { getHDThumbnailUrl } from '../../lib/video_utils'

@connect(
(state) => ({
Expand Down Expand Up @@ -55,7 +56,7 @@ export class VideoDebate extends React.PureComponent {

renderMeta(video) {
const title = `Vérification complète de : ${video.title}`
const image = video.thumbnail
const image = getHDThumbnailUrl(video)
const description = `${video.title} vérifiée citation par citation par la communauté CaptainFact`
return (
<Helmet>
Expand Down
2 changes: 1 addition & 1 deletion app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const MIN_REPUTATION_REMOVE_STATEMENT = 75
export const MIN_REPUTATION_RESTORE_ENTITY = 75
export const MIN_REPUTATION_REMOVE_SPEAKER = 75
export const MIN_REPUTATION_UPDATE_VIDEO = 75
export const MIN_REPUTATION_ADD_VIDEO = 15
export const MIN_REPUTATION_ADD_VIDEO = 75
export const MIN_REPUTATION_MODERATION = 125

/* ------ UI, animations ------ */
Expand Down
11 changes: 11 additions & 0 deletions app/lib/video_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ export const getTimecode = (videoPlayer, video, baseTimecode) => {
return getTimecodesOffset(video, videoPlayer) + baseTimecode
}

/**
* Returns HD thumbnail URL if any, otherwise returns the default thumbnail URL.
*/
export const getHDThumbnailUrl = (video) => {
if (video.youtube_id) {
return `https://img.youtube.com/vi/${video.youtube_id}/hqdefault.jpg`
}

return video.thumbnail
}

export const THUMBNAILS_SIZES = {
MEDIUM: 'MEDIUM',
LARGE: 'LARGE',
Expand Down
4 changes: 4 additions & 0 deletions app/styles/_components/App/sidebar.sass
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ $border-color: lightgrey

.menu-content
padding: 9px
& .tag
margin: 0 5px

.link-with-icon > i
width: 20px
Expand Down Expand Up @@ -104,6 +106,8 @@ $border-color: lightgrey
width: 100%
&> span
display: none
&> .tag
margin: 0 5px

.connect-register-buttons
margin-bottom: 5px
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.