Commit 9e6a5d5e authored by Ibnu Daru Aji's avatar Ibnu Daru Aji

amended previous commit.

parent 01218ec6
......@@ -18,7 +18,7 @@ getPostsInTopic ::
, YesodPersist (HandlerSite m)
, MonadHandler m
)
=> Key Posts
=> Key Topics
-> Int64
-> m [Entity Posts]
getPostsInTopic tid page
......
......@@ -38,7 +38,7 @@ replyTopicByPosting uid uname tid content = do
let fid = topicsForumId $ entityVal topic
num = topicsRepliesCount $ entityVal topic
page = floor $ (toRational num) / 25 + 1 :: Int64
pid <- liftHandler $ runDB $ insertPost tid (num + 1) uname uid content
pid <- liftHandler $ runDB $ insertPost tid (num + 2) uname uid content
liftHandler $
runDB $ do
updateForumIncrementReplyAndLasts
......@@ -47,4 +47,4 @@ replyTopicByPosting uid uname tid content = do
pid
now
updateTopicIncrementReplyAndLasts tid uname pid now
return (tid, page, num + 1)
return (tid, page, num + 2)
......@@ -10,6 +10,7 @@ import Data.Time.LocalTime
import Database.Esqueleto
import Flux.Forum
import Handler.Topic
data CreateTopicForm = CreateTopicForm
{ createTopicFormSubject :: Text
......@@ -60,6 +61,6 @@ postForumR fid = do
name
(createTopicFormSubject r)
(unTextarea $ createTopicFormContent r)
redirect $ ForumR fid -- we will back to it later.
redirect $ TopicPageR (fromSqlKey tid) 1
_ -> invalidArgs ["Come on..."]
_ -> invalidArgs ["Make up your mind!"]
......@@ -39,8 +39,8 @@ postTopicR tid = do
getTopicPageR :: Int64 -> Int64 -> Handler Html
getTopicPageR tid page = do
(uid, name, group) <- allowedToPost
posts <- getPostsInTopic (toSqlKey tid) page
topic <- getTopicById $ toSqlKey tid
posts <- getPostsInTopic (toSqlKey tid) page
forum <- getForumsInformation . topicsForumId . entityVal $ topic
(wid, enct) <- generateFormPost postForm
defaultLayout $(widgetFile "topic")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment