From f24aafd47b3efd96294ed51e533866ce01830dad Mon Sep 17 00:00:00 2001 From: David Sevilla Martin Date: Fri, 7 Feb 2020 09:36:38 -0500 Subject: [PATCH] a few fixes here & there - cache typehinting moved to Forum.ts, don't use button link in PostUser --- js/src/common/Application.ts | 8 +------- js/src/common/Model.ts | 2 ++ js/src/forum/Forum.ts | 7 +++++++ js/src/forum/components/CommentPost.tsx | 23 ++++++++--------------- js/src/forum/components/PostUser.tsx | 4 ++-- js/src/forum/utils/History.ts | 2 +- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/js/src/common/Application.ts b/js/src/common/Application.ts index 4b281d2d6..9ad55dedb 100644 --- a/js/src/common/Application.ts +++ b/js/src/common/Application.ts @@ -67,9 +67,7 @@ export default abstract class Application { * A local cache that can be used to store data at the application level, so * that is persists between different routes. */ - cache = { - notifications: null, - }; + cache: { [key: string]: any } = {}; routes = {}; @@ -243,10 +241,6 @@ export default abstract class Application { // Now make the request. If it's a failure, inspect the error that was // returned and show an alert containing its contents. - // const deferred = m.deferred(); - - // return new Promise((resolve, reject) => ) - return m.request(options).then( res => res, error => { diff --git a/js/src/common/Model.ts b/js/src/common/Model.ts index 9001c0ac1..306a8e941 100644 --- a/js/src/common/Model.ts +++ b/js/src/common/Model.ts @@ -12,6 +12,8 @@ export default class Model { */ data: any; + payload: any; + /** * The time at which the model's data was last updated. Watching the value * of this property is a fast way to retain/cache a subtree if data hasn't diff --git a/js/src/forum/Forum.ts b/js/src/forum/Forum.ts index 60041cb67..1bcdd082d 100644 --- a/js/src/forum/Forum.ts +++ b/js/src/forum/Forum.ts @@ -17,6 +17,7 @@ import CommentPost from './components/CommentPost'; import User from '../common/models/User'; import Post from '../common/models/Post'; import Discussion from '../common/models/Discussion'; +import Notification from '../common/models/Notification'; export default class Forum extends Application { routes = { @@ -40,6 +41,12 @@ export default class Forum extends Application { */ history: History = new History(); + cache: { + notifications?: Notification[]; + discussionList?: DiscussionList; + [key: string]: any; + } = {}; + postComponents = { comment: CommentPost, // discussionRenamed: DiscussionRenamedPost diff --git a/js/src/forum/components/CommentPost.tsx b/js/src/forum/components/CommentPost.tsx index a12a56b6b..ba40c93d2 100644 --- a/js/src/forum/components/CommentPost.tsx +++ b/js/src/forum/components/CommentPost.tsx @@ -35,21 +35,14 @@ export default class CommentPost extends Post { } content() { - // Note: we avoid using JSX for the