diff --git a/pkg/interface/src/logic/api/chat.ts b/pkg/interface/src/logic/api/chat.ts index ad6e5029d..26e1f65f0 100644 --- a/pkg/interface/src/logic/api/chat.ts +++ b/pkg/interface/src/logic/api/chat.ts @@ -81,7 +81,7 @@ export default class ChatApi extends BaseApi { * If we don't host the chat, then it just leaves */ delete(path: Path) { - this.viewAction({ delete: { 'app-path': path } }); + return this.viewAction({ delete: { 'app-path': path } }); } /** @@ -157,7 +157,7 @@ export default class ChatApi extends BaseApi { this.store.state.pendingMessages.set(path, [envelope]); } - this.store.setState({ + return this.store.setState({ pendingMessages: this.store.state.pendingMessages }); } diff --git a/pkg/interface/src/logic/api/graph.ts b/pkg/interface/src/logic/api/graph.ts index d58332202..0c62f835d 100644 --- a/pkg/interface/src/logic/api/graph.ts +++ b/pkg/interface/src/logic/api/graph.ts @@ -21,7 +21,7 @@ export default class GraphApi extends BaseApi { } addGraph(ship: Patp, name: string, graph: any, mark: any) { - this.storeAction({ + return this.storeAction({ 'add-graph': { resource: { ship, name }, graph, @@ -31,7 +31,7 @@ export default class GraphApi extends BaseApi { } removeGraph(ship: Patp, name: string) { - this.storeAction({ + return this.storeAction({ 'remove-graph': { resource: { ship, name } } @@ -45,7 +45,7 @@ export default class GraphApi extends BaseApi { children: { empty: null } }; - this.storeAction({ + return this.storeAction({ 'add-nodes': { resource: { ship, name }, nodes @@ -54,7 +54,7 @@ export default class GraphApi extends BaseApi { } addNodes(ship: Patp, name: string, nodes: Object) { - this.storeAction({ + return this.storeAction({ 'add-nodes': { resource: { ship, name }, nodes @@ -63,7 +63,7 @@ export default class GraphApi extends BaseApi { } removeNodes(ship: Patp, name: string, indices: string[]) { - this.storeAction({ + return this.storeAction({ 'remove-nodes': { resource: { ship, name }, indices @@ -72,7 +72,7 @@ export default class GraphApi extends BaseApi { } getKeys() { - this.scry('graph-store', '/keys') + return this.scry('graph-store', '/keys') .then((keys) => { this.store.handleEvent({ data: keys @@ -81,7 +81,7 @@ export default class GraphApi extends BaseApi { } getTags() { - this.scry('graph-store', '/tags') + return this.scry('graph-store', '/tags') .then((tags) => { this.store.handleEvent({ data: tags @@ -90,7 +90,7 @@ export default class GraphApi extends BaseApi { } getTagQueries() { - this.scry('graph-store', '/tag-queries') + return this.scry('graph-store', '/tag-queries') .then((tagQueries) => { this.store.handleEvent({ data: tagQueries @@ -99,7 +99,7 @@ export default class GraphApi extends BaseApi { } getGraph(ship: string, resource: string) { - this.scry('graph-store', `/graph/${ship}/${resource}`) + return this.scry('graph-store', `/graph/${ship}/${resource}`) .then((graph) => { this.store.handleEvent({ data: graph @@ -108,7 +108,7 @@ export default class GraphApi extends BaseApi { } getGraphSubset(ship: string, resource: string, start: string, end: start) { - this.scry( + return this.scry( 'graph-store', `/graph-subset/${ship}/${resource}/${end}/${start}` ).then((subset) => { @@ -119,7 +119,7 @@ export default class GraphApi extends BaseApi { } getNode(ship: string, resource: string, index: string) { - this.scry( + return this.scry( 'graph-store', `/node/${ship}/${resource}/${index}` ).then((node) => { diff --git a/pkg/interface/src/logic/api/launch.ts b/pkg/interface/src/logic/api/launch.ts index 0eeca42e8..30661df83 100644 --- a/pkg/interface/src/logic/api/launch.ts +++ b/pkg/interface/src/logic/api/launch.ts @@ -5,31 +5,31 @@ import { StoreState } from '../store/type'; export default class LaunchApi extends BaseApi { add(name: string, tile = { basic : { title: '', linkedUrl: '', iconUrl: '' }}) { - this.launchAction({ add: { name, tile } }); + return this.launchAction({ add: { name, tile } }); } remove(name: string) { - this.launchAction({ remove: name }); + return this.launchAction({ remove: name }); } changeOrder(orderedTiles: string[] = []) { - this.launchAction({ 'change-order': orderedTiles }); + return this.launchAction({ 'change-order': orderedTiles }); } changeFirstTime(firstTime = true) { - this.launchAction({ 'change-first-time': firstTime }); + return this.launchAction({ 'change-first-time': firstTime }); } changeIsShown(name: string, isShown = true) { - this.launchAction({ 'change-is-shown': { name, isShown }}); + return this.launchAction({ 'change-is-shown': { name, isShown }}); } weather(latlng: any) { - this.action('weather', 'json', latlng); + return this.action('weather', 'json', latlng); } private launchAction(data) { - this.action('launch', 'launch-action', data); + return this.action('launch', 'launch-action', data); } } diff --git a/pkg/interface/src/logic/api/links.ts b/pkg/interface/src/logic/api/links.ts index e3ad42f5d..d3beec02a 100644 --- a/pkg/interface/src/logic/api/links.ts +++ b/pkg/interface/src/logic/api/links.ts @@ -10,7 +10,7 @@ export default class LinksApi extends BaseApi { getCommentsPage(path: Path, url: string, page: number) { const strictUrl = stringToTa(url); const endpoint = '/json/' + page + '/discussions/' + strictUrl + path; - this.fetchLink( + return this.fetchLink( endpoint, (res) => { if (res.data['link-update']['initial-discussions']) { @@ -28,7 +28,7 @@ export default class LinksApi extends BaseApi { getPage(path: Path, page: number) { const endpoint = '/json/' + page + '/submissions' + path; - this.fetchLink( + return this.fetchLink( endpoint, (dat) => { this.store.handleEvent(dat); @@ -41,7 +41,7 @@ export default class LinksApi extends BaseApi { getSubmission(path: Path, url: string, callback) { const strictUrl = stringToTa(url); const endpoint = '/json/0/submission/' + strictUrl + path; - this.fetchLink( + return this.fetchLink( endpoint, (res) => { if (res.data?.['link-update']?.submission) { @@ -118,7 +118,7 @@ export default class LinksApi extends BaseApi { } private fetchLink(path: Path, result, fail, quit) { - this.subscribe.bind(this)( + return this.subscribe.bind(this)( path, 'PUT', this.ship, diff --git a/pkg/interface/src/logic/api/publish.ts b/pkg/interface/src/logic/api/publish.ts index 5b49aabfc..ce9e0a49a 100644 --- a/pkg/interface/src/logic/api/publish.ts +++ b/pkg/interface/src/logic/api/publish.ts @@ -10,7 +10,7 @@ export default class PublishApi extends BaseApi { } fetchNotebooks() { - fetch('/publish-view/notebooks.json') + return fetch('/publish-view/notebooks.json') .then(response => response.json()) .then((json) => { this.handleEvent({ @@ -21,7 +21,7 @@ export default class PublishApi extends BaseApi { } fetchNotebook(host: PatpNoSig, book: BookId) { - fetch(`/publish-view/${host}/${book}.json`) + return fetch(`/publish-view/${host}/${book}.json`) .then(response => response.json()) .then((json) => { this.handleEvent({ @@ -34,7 +34,7 @@ export default class PublishApi extends BaseApi { } fetchNote(host: PatpNoSig, book: BookId, note: NoteId) { - fetch(`/publish-view/${host}/${book}/${note}.json`) + return fetch(`/publish-view/${host}/${book}/${note}.json`) .then(response => response.json()) .then((json) => { this.handleEvent({ @@ -48,7 +48,7 @@ export default class PublishApi extends BaseApi { } fetchNotesPage(host: PatpNoSig, book: BookId, start: number, length: number) { - fetch(`/publish-view/notes/${host}/${book}/${start}/${length}.json`) + return fetch(`/publish-view/notes/${host}/${book}/${start}/${length}.json`) .then(response => response.json()) .then((json) => { this.handleEvent({ @@ -63,7 +63,7 @@ export default class PublishApi extends BaseApi { } fetchCommentsPage(host: PatpNoSig, book: BookId, note: NoteId, start: number, length: number) { - fetch(`/publish-view/comments/${host}/${book}/${note}/${start}/${length}.json`) + return fetch(`/publish-view/comments/${host}/${book}/${note}/${start}/${length}.json`) .then(response => response.json()) .then((json) => { this.handleEvent({ @@ -78,6 +78,24 @@ export default class PublishApi extends BaseApi { }); } + subscribeNotebook(who: PatpNoSig, book: BookId) { + return this.publishAction({ + subscribe: { + who, + book + } + }); + } + + unsubscribeNotebook(who: PatpNoSig, book: BookId) { + return this.publishAction({ + unsubscribe: { + who, + book + } + }); + } + publishAction(act: any) { return this.action('publish', 'publish-action', act); } diff --git a/pkg/interface/src/logic/api/s3.ts b/pkg/interface/src/logic/api/s3.ts index e5b67595a..834cc6ffe 100644 --- a/pkg/interface/src/logic/api/s3.ts +++ b/pkg/interface/src/logic/api/s3.ts @@ -6,31 +6,31 @@ import {S3Update} from '../../types/s3-update'; export default class S3Api extends BaseApi { setCurrentBucket(bucket: string) { - this.s3Action({ 'set-current-bucket': bucket }); + return this.s3Action({ 'set-current-bucket': bucket }); } addBucket(bucket: string) { - this.s3Action({ 'add-bucket': bucket }); + return this.s3Action({ 'add-bucket': bucket }); } removeBucket(bucket: string) { - this.s3Action({ 'remove-bucket': bucket }); + return this.s3Action({ 'remove-bucket': bucket }); } setEndpoint(endpoint: string) { - this.s3Action({ 'set-endpoint': endpoint }); + return this.s3Action({ 'set-endpoint': endpoint }); } setAccessKeyId(accessKeyId: string) { - this.s3Action({ 'set-access-key-id': accessKeyId }); + return this.s3Action({ 'set-access-key-id': accessKeyId }); } setSecretAccessKey(secretAccessKey: string) { - this.s3Action({ 'set-secret-access-key': secretAccessKey }); + return this.s3Action({ 'set-secret-access-key': secretAccessKey }); } private s3Action(data: any) { - this.action('s3-store', 's3-action', data); + return this.action('s3-store', 's3-action', data); } }