mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
Fix offlie behavior of the news
This commit is contained in:
parent
29f060d9bd
commit
dc1371063b
|
@ -40,6 +40,7 @@ export default function getApp(theState) {
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
|
|
||||||
|
console.log('Did mount!');
|
||||||
const uiComDate = 'ui-last-comment-date';
|
const uiComDate = 'ui-last-comment-date';
|
||||||
const uiComEtag = 'ui-last-comments-etag';
|
const uiComEtag = 'ui-last-comments-etag';
|
||||||
const uiLastNews = 'ui-last-news';
|
const uiLastNews = 'ui-last-news';
|
||||||
|
@ -56,17 +57,14 @@ export default function getApp(theState) {
|
||||||
'User-Agent': 'anticensorship-russia',
|
'User-Agent': 'anticensorship-russia',
|
||||||
};
|
};
|
||||||
if (oldEtag) {
|
if (oldEtag) {
|
||||||
|
|
||||||
Object.assign(headers, {
|
Object.assign(headers, {
|
||||||
'If-None-Match': oldEtag,
|
'If-None-Match': oldEtag,
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
const params = {
|
const params = {
|
||||||
headers: new Headers(headers),
|
headers: new Headers(headers),
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('headers', headers);
|
|
||||||
const [comments, etag] = await fetch(
|
const [comments, etag] = await fetch(
|
||||||
`https://api.github.com/repos/edge-ware/edge-ware.github.io/issues/1/comments${query}`,
|
`https://api.github.com/repos/edge-ware/edge-ware.github.io/issues/1/comments${query}`,
|
||||||
params
|
params
|
||||||
|
@ -75,10 +73,14 @@ export default function getApp(theState) {
|
||||||
res.status !== 304 ? res.json() : false,
|
res.status !== 304 ? res.json() : false,
|
||||||
res.headers.get('ETag')
|
res.headers.get('ETag')
|
||||||
]),
|
]),
|
||||||
(err) => this.showError({message: 'Что-то не так с сетью. Не удалось достать новости.'})
|
(err) => {
|
||||||
|
|
||||||
|
this.showErrors({message: 'Что-то не так с сетью. Не удалось достать новости.'});
|
||||||
|
return [false, false];
|
||||||
|
|
||||||
|
}
|
||||||
);
|
);
|
||||||
if (etag) {
|
if (etag) {
|
||||||
console.log('new ETag', etag);
|
|
||||||
localStorage[uiComEtag] = etag;
|
localStorage[uiComEtag] = etag;
|
||||||
}
|
}
|
||||||
if (!(comments && comments.length)) {
|
if (!(comments && comments.length)) {
|
||||||
|
@ -191,6 +193,7 @@ export default function getApp(theState) {
|
||||||
|
|
||||||
render(originalProps) {
|
render(originalProps) {
|
||||||
|
|
||||||
|
console.log('Render');
|
||||||
const props = Object.assign({}, originalProps, {
|
const props = Object.assign({}, originalProps, {
|
||||||
funs: {
|
funs: {
|
||||||
setStatusTo: this.setStatusTo.bind(this),
|
setStatusTo: this.setStatusTo.bind(this),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user