Merge pull request #2979 from urbit/lf/publish-alignment

publish: fix store reducers
This commit is contained in:
matildepark 2020-06-05 14:19:00 -04:00 committed by GitHub
commit c9986074b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 13 deletions

View File

@ -2124,7 +2124,6 @@
[[[~ %json] [%'publish-view' %notebooks ~]] ~]
%- json-response:gen
%- json-to-octs
%+ frond:enjs:format %publish-response
(notebooks-map:enjs our.bol books)
::
:: notes pagination
@ -2144,7 +2143,6 @@
not-found:gen
%- json-response:gen
%- json-to-octs
%+ frond:enjs:format %publish-response
:- %o
(notes-page:enjs notes.u.book u.start u.length)
::
@ -2169,7 +2167,6 @@
not-found:gen
%- json-response:gen
%- json-to-octs
%+ frond:enjs:format %publish-response
(comments-page:enjs comments.u.note u.start u.length)
::
:: single notebook with initial 50 notes in short form, as json
@ -2186,9 +2183,7 @@
(~(uni by p.notebook-json) (notes-page:enjs notes.u.book 0 50))
=. p.notebook-json
(~(put by p.notebook-json) %subscribers (get-subscribers-json book-name))
=/ jon=json
(frond:enjs:format %publish-response (pairs notebook+notebook-json ~))
(json-response:gen (json-to-octs jon))
(json-response:gen (json-to-octs (pairs notebook+notebook-json ~)))
::
:: single note, with initial 50 comments, as json
[[[~ %json] [%'publish-view' @ @ @ ~]] ~]
@ -2202,7 +2197,6 @@
=/ note=(unit note) (~(get by notes.u.book) note-name)
?~ note not-found:gen
=/ jon=json
%+ frond %publish-response:enjs:format
o+(note-presentation:enjs u.book note-name u.note)
(json-response:gen (json-to-octs jon))
==

View File

@ -2,11 +2,16 @@ import BaseApi from './base';
export default class PublishApi extends BaseApi {
handleEvent(data) {
this.store.handleEvent({ data: { 'publish-response' : data }});
}
fetchNotebooks() {
fetch('/publish-view/notebooks.json')
.then(response => response.json())
.then((json) => {
this.store.handleEvent({
this.handleEvent({
type: 'notebooks',
data: json
});
@ -17,7 +22,7 @@ export default class PublishApi extends BaseApi {
fetch(`/publish-view/${host}/${book}.json`)
.then(response => response.json())
.then((json) => {
this.store.handleEvent({
this.handleEvent({
type: 'notebook',
data: json,
host: host,
@ -30,7 +35,7 @@ export default class PublishApi extends BaseApi {
fetch(`/publish-view/${host}/${book}/${note}.json`)
.then(response => response.json())
.then((json) => {
this.store.handleEvent({
this.handleEvent({
type: 'note',
data: json,
host: host,
@ -44,7 +49,7 @@ export default class PublishApi extends BaseApi {
fetch(`/publish-view/notes/${host}/${book}/${start}/${length}.json`)
.then(response => response.json())
.then((json) => {
this.store.handleEvent({
this.handleEvent({
type: 'notes-page',
data: json,
host: host,
@ -59,7 +64,7 @@ export default class PublishApi extends BaseApi {
fetch(`/publish-view/comments/${host}/${book}/${note}/${start}/${length}.json`)
.then(response => response.json())
.then((json) => {
this.store.handleEvent({
this.handleEvent({
type: 'comments-page',
data: json,
host: host,
@ -76,7 +81,7 @@ export default class PublishApi extends BaseApi {
if (this.store.state.sidebarShown === true) {
sidebarBoolean = false;
}
this.store.handleEvent({
this.handleEvent({
type: 'local',
data: {
'sidebarToggle': sidebarBoolean