Move Action and Routes into the Common git submodule

- also fixes to display fewer things because everything is unbearably
  slow on mobile even on a lan, I hope that this is something that can
  be profiled and optimized out since rendering with very few posts
  is reasonably quick.
    - things to check: String conversions
This commit is contained in:
towards-a-new-leftypol 2024-03-05 18:15:43 -05:00
parent c8f720f05b
commit 1874f3a043
10 changed files with 27 additions and 90 deletions

View File

@ -1,8 +1,13 @@
- get embeds working ✓
- need to implement search
- need to implement search
- change urls / history when time-travelling
- remove duplicate threads from view (duplicate because the OP has multiple pictures) ✓
- optimize rendering (especially for mobile)
- need to profile the code, perhaps profiling the views by removing certain elements (like the body of a post)
and measuring the rendering speed
- server-side rendering
- make new servant project
- copy isomorphic example
- control to manually put in the datetime instead of using the slider
for fine-grained control
- have some process respond to http calls from the board to inform the db of new posts
@ -15,7 +20,6 @@
just there to preserve links. the time travel thing is a bit of a gimmick
- "infinite" scrolling
- just load more!
- more granular actions to display what is causing slowdowns (esp on mobile)
- fix thumbnails for older posts ✓
- need to support flags
- need to support mod actions like saging a thread or deleting a post

View File

@ -63,7 +63,7 @@ executable chandlr
-- Modules included in this executable, other than Main.
other-modules: Component.CatalogGrid
Action
Common.FrontEnd.Action
Network.Http
Network.Client
Network.ClientTypes
@ -78,7 +78,7 @@ executable chandlr
Component.Thread.Model
Component.Thread.Embed
Component.BodyRender
Routes
Common.FrontEnd.Routes
Common.AttachmentType
Parsing.BodyParser
Parsing.QuoteLinkParser

View File

@ -3,7 +3,7 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="postgrest-root" content="http://10.4.0.96:3000">
<meta name="postgrest-fetch-count" content="500">
<meta name="postgrest-fetch-count" content="50">
<meta name="media-root" content="http://10.4.0.1:8888">
<title>Chandlr</title>
<link href="static/style.css" rel="stylesheet" />

View File

@ -1,39 +0,0 @@
{-# LANGUAGE ExistentialQuantification #-}
module Action where
import Data.Text (Text)
import Data.Aeson (FromJSON)
import Data.Int (Int64)
import Data.Time.Clock (UTCTime)
import Data.JSString (JSString)
import Miso (URI)
import qualified Component.CatalogGrid as Grid
import qualified Network.ClientTypes as C
import Network.CatalogPostType (CatalogPost)
import Network.Http (HttpResult)
import Network.SiteType (Site)
import qualified Component.ThreadView as Thread
import qualified Component.TimeControl as TC
import qualified Component.Search.SearchTypes as Search
data GetThreadArgs = GetThreadArgs
{ website :: Text
, board_pathpart :: Text
, board_thread_id :: Int64
}
data Action
= GridAction Grid.Action
| GetThread GetThreadArgs
| HaveLatest (HttpResult [ CatalogPost ])
| HaveThread (HttpResult [ Site ])
| forall a. (FromJSON a) => ClientAction (HttpResult a -> Action) (C.Action a)
| ThreadAction Thread.Action
| TimeAction TC.Time
| SearchAction Search.Action
| GoToTime UTCTime
| ChangeURI URI
| SearchResults JSString
| NoAction

@ -1 +1 @@
Subproject commit 53e9a74af4083bf9dd567d94b6ab9a701c5e20ae
Subproject commit a77cfddc7a757bef9c1ef578c3a5eab54795cb37

View File

@ -59,7 +59,7 @@ update iface (SearchResult result) model = model <# do
case result of
Error -> do
consoleLog $ "Error!"
return $ (passAction iface) NoAction
return $ passAction iface $ PassPostsToSelf []
HttpResponse {..} -> do
consoleLog $ (pack $ show $ status_code) <> " " <> (pack $ status_text)

View File

@ -20,6 +20,7 @@ import Miso
, p_
, Attribute
, text
, target_
)
import Data.Foldable (toList)
@ -83,6 +84,7 @@ file media_root site multifile a = div_
]
, a_
[ href_ file_url
, target_ "blank_"
]
[ img_
(

View File

@ -43,8 +43,8 @@ import GHCJS.DOM.ParentNode (querySelector)
import GHCJS.DOM.Element (getAttribute)
import Servant.API
import Action
import Routes
import Common.FrontEnd.Action
import Common.FrontEnd.Routes
import qualified Network.Client as Client
import Network.CatalogPostType (CatalogPost)
import qualified Network.CatalogPostType as CatalogPost
@ -267,11 +267,12 @@ mainUpdate (GetThread GetThreadArgs {..}) m = m <# do
where
new_current_uri :: URI
new_current_uri = (current_uri m) {
uriPath = T.unpack website
</> T.unpack board_pathpart
</> show board_thread_id
}
new_current_uri = (current_uri m)
{ uriPath = T.unpack website
</> T.unpack board_pathpart
</> show board_thread_id
, uriQuery = ""
}
mainUpdate (ChangeURI uri) m = m { current_uri = uri } <# do
consoleLog $ "ChangeURI! " `append` (pack $ show $ uri)

View File

@ -31,7 +31,7 @@ import Miso.String (toMisoString)
import qualified Network.Http as Http
import Network.CatalogPostType (CatalogPost)
import Network.SiteType (Site)
import qualified Action as A
import qualified Common.FrontEnd.Action as A
import Network.ClientTypes
@ -51,7 +51,10 @@ data FetchCatalogArgs = FetchCatalogArgs
} deriving (Generic, ToJSON)
data SearchPostsArgs = SearchPostsArgs { search_text :: JSString }
data SearchPostsArgs = SearchPostsArgs
{ search_text :: JSString
, max_rows :: Int
}
deriving (Generic, ToJSON)
@ -102,5 +105,6 @@ search m query iface =
where
payload = Just $ SearchPostsArgs
{ search_text = query
, max_rows = 100
}

View File

@ -1,35 +0,0 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Routes where
import Data.Text (Text)
import Data.Int (Int64)
import Miso (View)
import Servant.API
import Action
type Route
= R_Latest
:<|> R_Thread
:<|> R_SearchResults
type R_Latest = View Action
-- Show selected thread
-- - <website>/<board>/res/<thread_id>
type R_Thread
= Capture "website" Text
:> Capture "board" Text
:> Capture "board_thread_id" BoardThreadId
:> View Action
type R_SearchResults
= "search"
:> QueryParam "search" Text
:> View Action
type BoardThreadId = Int64