mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 14:45:56 +08:00
adds @Ducz0r suggestions
This commit is contained in:
parent
182e3dcc37
commit
5a31df7204
|
@ -15,7 +15,7 @@ module ClientApi
|
|||
UserNotification.seen_by_user(current_user)
|
||||
end
|
||||
|
||||
def unreaded_notifications_number
|
||||
def unread_notifications_count
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
import React, { Component } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { NavDropdown } from "react-bootstrap";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import styled from "styled-components";
|
||||
|
||||
import {
|
||||
getRecentNotifications,
|
||||
getUnreadedNotificationsNumber
|
||||
getUnreadNotificationsCount
|
||||
} from "../../../services/api/notifications_api";
|
||||
import {
|
||||
MAIN_COLOR_BLUE,
|
||||
WILD_SAND_COLOR,
|
||||
MYSTIC_COLOR
|
||||
} from "../../../config/constants/colors";
|
||||
import {
|
||||
SETTINGS_ACCOUNT_PREFERENCES
|
||||
} from "../../../config/routes"
|
||||
|
||||
import NotificationItem from "./NotificationItem";
|
||||
import Spinner from "../../Spinner";
|
||||
|
@ -95,7 +99,7 @@ class NotificationsDropdown extends Component {
|
|||
}
|
||||
|
||||
loadStatus() {
|
||||
getUnreadedNotificationsNumber().then(response => {
|
||||
getUnreadNotificationsCount().then(response => {
|
||||
this.setState({ notificationsCount: parseInt(response.count, 10) });
|
||||
});
|
||||
}
|
||||
|
@ -144,9 +148,9 @@ class NotificationsDropdown extends Component {
|
|||
<FormattedMessage id="notifications.dropdown_title" />
|
||||
</span>
|
||||
<span className="pull-right">
|
||||
<a href="/users/settings/account/preferences">
|
||||
<Link to={SETTINGS_ACCOUNT_PREFERENCES}>
|
||||
<FormattedMessage id="notifications.dropdown_settings_link" />
|
||||
</a>
|
||||
</Link>
|
||||
</span>
|
||||
</StyledListHeader>
|
||||
{this.renderNotifications()}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// notifications
|
||||
export const RECENT_NOTIFICATIONS_PATH = "/client_api/recent_notifications";
|
||||
export const UNREADED_NOTIFICATIONS_PATH =
|
||||
"/client_api/unreaded_notifications_number";
|
||||
"/client_api/unread_notifications_count";
|
||||
|
|
|
@ -8,7 +8,7 @@ export const getRecentNotifications = () => {
|
|||
return axiosInstance.get(RECENT_NOTIFICATIONS_PATH).then(({ data }) => data);
|
||||
};
|
||||
|
||||
export const getUnreadedNotificationsNumber = () => {
|
||||
export const getUnreadNotificationsCount = () => {
|
||||
return axiosInstance
|
||||
.get(UNREADED_NOTIFICATIONS_PATH)
|
||||
.then(({ data }) => data);
|
||||
|
|
|
@ -27,8 +27,8 @@ Rails.application.routes.draw do
|
|||
end
|
||||
# notifications
|
||||
get '/recent_notifications', to: 'notifications#recent_notifications'
|
||||
get '/unreaded_notifications_number',
|
||||
to: 'notifications#unreaded_notifications_number'
|
||||
get '/unread_notifications_count',
|
||||
to: 'notifications#unread_notifications_count'
|
||||
|
||||
# users
|
||||
get '/current_user_info', to: 'users/users#current_user_info'
|
||||
|
|
|
@ -19,7 +19,7 @@ describe ClientApi::NotificationsController, type: :controller do
|
|||
|
||||
describe '#unreaded_notifications_number' do
|
||||
it 'returns a number of unreaded notifications' do
|
||||
get :unreaded_notifications_number, format: :json
|
||||
get :unread_notifications_count, format: :json
|
||||
expect(response).to be_success
|
||||
expect(response.body).to include('count')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue