apply prettier formating

This commit is contained in:
Prettier
2018-07-07 01:17:37 +04:00
committed by Aleksey Gurianov
parent 5d1201351a
commit 2df3aa01d4
38 changed files with 215 additions and 190 deletions
+83 -69
View File
@@ -15,94 +15,108 @@ export const getPostComments = ({ sort, url }) => fetcher.get(`/find?url=${url}&
export const getLastComments = ({ siteId, max }) => fetcher.get(`/last/${max}?site=${siteId}`);
export const getCommentsCount = ({ urls, siteId }) => fetcher.post({
url: `/counts?site=${siteId}`,
body: urls,
});
export const getCommentsCount = ({ urls, siteId }) =>
fetcher.post({
url: `/counts?site=${siteId}`,
body: urls,
});
export const getComment = ({ id }) => fetcher.get(`/id/${id}?url=${url}`);
export const getUserComments = ({ user, limit }) => fetcher.get(`/comments?user=${user}&limit=${limit}`);
export const putCommentVote = ({ id, url, value }) => fetcher.put({
url: `/vote/${id}?url=${url}&vote=${value}`,
withCredentials: true,
});
export const putCommentVote = ({ id, url, value }) =>
fetcher.put({
url: `/vote/${id}?url=${url}&vote=${value}`,
withCredentials: true,
});
export const addComment = ({ text, pid }) => fetcher.post({
url: '/comment',
body: {
text,
locator: {
site: siteId,
url,
export const addComment = ({ text, pid }) =>
fetcher.post({
url: '/comment',
body: {
text,
locator: {
site: siteId,
url,
},
...(pid ? { pid } : {}),
},
...(pid ? { pid } : {}),
},
withCredentials: true,
});
withCredentials: true,
});
export const updateComment = ({ text, id }) => fetcher.put({
url: `/comment/${id}?url=${url}`,
body: {
text,
},
withCredentials: true,
});
export const updateComment = ({ text, id }) =>
fetcher.put({
url: `/comment/${id}?url=${url}`,
body: {
text,
},
withCredentials: true,
});
export const getPreview = ({ text }) => fetcher.post({
url: '/preview',
body: {
text,
},
withCredentials: true,
});
export const getPreview = ({ text }) =>
fetcher.post({
url: '/preview',
body: {
text,
},
withCredentials: true,
});
export const getUser = () => fetcher.get({
url: '/user',
withCredentials: true
});
export const getUser = () =>
fetcher.get({
url: '/user',
withCredentials: true,
});
/* admin */
export const pinComment = ({ id, url }) => fetcher.put({
url: `/admin/pin/${id}?url=${url}&pin=1`,
withCredentials: true,
});
export const pinComment = ({ id, url }) =>
fetcher.put({
url: `/admin/pin/${id}?url=${url}&pin=1`,
withCredentials: true,
});
export const unpinComment = ({ id, url }) => fetcher.put({
url: `/admin/pin/${id}?url=${url}&pin=0`,
withCredentials: true,
});
export const unpinComment = ({ id, url }) =>
fetcher.put({
url: `/admin/pin/${id}?url=${url}&pin=0`,
withCredentials: true,
});
export const setVerifyStatus = ({ id }) => fetcher.put({
url: `/admin/verify/${id}?verified=1`,
withCredentials: true,
});
export const setVerifyStatus = ({ id }) =>
fetcher.put({
url: `/admin/verify/${id}?verified=1`,
withCredentials: true,
});
export const removeVerifyStatus = ({ id }) => fetcher.put({
url: `/admin/verify/${id}?verified=0`,
withCredentials: true,
});
export const removeVerifyStatus = ({ id }) =>
fetcher.put({
url: `/admin/verify/${id}?verified=0`,
withCredentials: true,
});
export const removeComment = ({ id }) => fetcher.delete({
url: `/admin/comment/${id}?url=${url}`,
withCredentials: true,
});
export const removeComment = ({ id }) =>
fetcher.delete({
url: `/admin/comment/${id}?url=${url}`,
withCredentials: true,
});
export const blockUser = ({ id }) => fetcher.put({
url: `/admin/user/${id}?block=1`,
withCredentials: true,
});
export const blockUser = ({ id }) =>
fetcher.put({
url: `/admin/user/${id}?block=1`,
withCredentials: true,
});
export const unblockUser = ({ id }) => fetcher.put({
url: `/admin/user/${id}?block=0`,
withCredentials: true,
});
export const unblockUser = ({ id }) =>
fetcher.put({
url: `/admin/user/${id}?block=0`,
withCredentials: true,
});
export const getBlocked = () => fetcher.get({
url: '/admin/blocked',
withCredentials: true,
});
export const getBlocked = () =>
fetcher.get({
url: '/admin/blocked',
withCredentials: true,
});
export default {
logOut,
+1 -1
View File
@@ -32,4 +32,4 @@ module.exports = {
DEFAULT_SORT,
LS_COLLAPSE_KEY,
LS_SORT_KEY,
};
};
+2 -6
View File
@@ -8,12 +8,8 @@ const methods = ['get', 'post', 'put', 'patch', 'delete', 'head'];
methods.forEach(method => {
fetcher[method] = data => {
const {
url,
body = {},
withCredentials = false,
overriddenApiBase = API_BASE,
} = (typeof data === 'string' ? { url: data } : data);
const { url, body = {}, withCredentials = false, overriddenApiBase = API_BASE } =
typeof data === 'string' ? { url: data } : data;
const basename = `${BASE_URL}${overriddenApiBase}`;
return new Promise((resolve, reject) => {
+4 -3
View File
@@ -5,8 +5,8 @@ Promise.prototype.finally = function finallyFn(callback) {
const constructor = this.constructor;
return this.then(
(value) => constructor.resolve(callback()).then(() => value),
(reason) => constructor.resolve(callback()).then(() => reason)
value => constructor.resolve(callback()).then(() => value),
reason => constructor.resolve(callback()).then(() => reason)
);
};
@@ -20,7 +20,8 @@ export default function loadPolyfills() {
'includes' in Array.prototype &&
'assign' in Object &&
'keys' in Object
) return Promise.resolve();
)
return Promise.resolve();
return import(/* webpackChunkName: "polyfills" */ 'core-js');
};
+9 -5
View File
@@ -1,8 +1,12 @@
const querySettings = window.location.search.substr(1).split('&').reduce((acc, param) => {
const pair = param.split('=');
acc[pair[0]] = decodeURIComponent(pair[1]);
return acc;
}, {}) || {};
const querySettings =
window.location.search
.substr(1)
.split('&')
.reduce((acc, param) => {
const pair = param.split('=');
acc[pair[0]] = decodeURIComponent(pair[1]);
return acc;
}, {}) || {};
export const siteId = querySettings['site_id'];
export const url = querySettings['url'];
-1
View File
@@ -19,7 +19,6 @@ class Store {
this.listeners[key].push(cb);
}
set(key, obj) {
this.data[key] = obj;
+2 -2
View File
@@ -6,8 +6,8 @@ describe('Store', () => {
store.set('comments', []);
store.onUpdate('comments', listener);
store.addComment({id:`new`});
store.addComment({ id: `new` });
expect(listener).toBeCalledWith([{"comment": {"id": "new"}}]);
expect(listener).toBeCalledWith([{ comment: { id: 'new' } }]);
});
});