From 335e4479a176cc968047d28cd172dc8f7f607947 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Fri, 5 Jun 2020 12:10:18 +1000 Subject: [PATCH] publish: fix store reducers --- pkg/arvo/app/publish.hoon | 8 +------- pkg/interface/src/api/publish.js | 17 +++++++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/arvo/app/publish.hoon b/pkg/arvo/app/publish.hoon index 9e7377c75d..62a95a5bb2 100644 --- a/pkg/arvo/app/publish.hoon +++ b/pkg/arvo/app/publish.hoon @@ -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)) == diff --git a/pkg/interface/src/api/publish.js b/pkg/interface/src/api/publish.js index 453fa874ec..d58b300746 100644 --- a/pkg/interface/src/api/publish.js +++ b/pkg/interface/src/api/publish.js @@ -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