diff options
author | Yorhel <git@yorhel.nl> | 2019-12-30 15:35:46 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-12-30 15:35:46 +0100 |
commit | 8143e41a59efb8d7220da458e0a94b5b839179b2 (patch) | |
tree | 6eaa0eddf45541f2b121bf14d3aea20be16f56a1 | |
parent | d1bb5b82255c764edecc659c78d5b9f4e36555e8 (diff) |
Discussions: Discourage necroing old and inactive threads
-rw-r--r-- | elm/Discussions/Reply.elm | 32 | ||||
-rw-r--r-- | lib/VNWeb/Discussions/Thread.pm | 16 |
2 files changed, 33 insertions, 15 deletions
diff --git a/elm/Discussions/Reply.elm b/elm/Discussions/Reply.elm index 69d112cd..c6e48a8e 100644 --- a/elm/Discussions/Reply.elm +++ b/elm/Discussions/Reply.elm @@ -11,7 +11,7 @@ import Gen.Api as GApi import Gen.DiscussionsReply as GDR -main : Program Int Model Msg +main : Program GDR.Recv Model Msg main = Browser.element { init = \e -> (init e, Cmd.none) , view = view @@ -23,20 +23,23 @@ main = Browser.element type alias Model = { state : Api.State , tid : Int + , old : Bool , msg : TP.Model } -init : Int -> Model -init tid = +init : GDR.Recv -> Model +init e = { state = Api.Normal - , tid = tid + , tid = e.tid + , old = e.old , msg = TP.bbcode "" } type Msg - = Content TP.Msg + = NotOldAnymore + | Content TP.Msg | Submit | Submitted GApi.Response @@ -44,6 +47,7 @@ type Msg update : Msg -> Model -> (Model, Cmd Msg) update msg model = case msg of + NotOldAnymore -> ({ model | old = False }, Cmd.none) Content m -> let (nm,nc) = TP.update m model.msg in ({ model | msg = nm }, Cmd.map Content nc) Submit -> @@ -57,8 +61,19 @@ update msg model = view : Model -> Html Msg view model = form_ Submit (model.state == Api.Loading) - [ div [ class "mainbox" ] - [ fieldset [ class "submit" ] + [ div [ class "mainbox" ] <| [ + if model.old + then + p [ class "center" ] + [ text "This thread has not seen any activity for more than 6 months, but you may still " + , a [ href "#", onClickD NotOldAnymore ] [ text "reply" ] + , text " if you have something relevant to add." + , text " If your message is not directly relevant to this thread, perhaps it's better to " + , a [ href "/t/ge/new" ] [ text "create a new thread" ] + , text " instead." + ] + else + fieldset [ class "submit" ] [ TP.view "msg" model.msg Content 600 ([rows 4, cols 50] ++ GDR.valMsg) [ b [] [ text "Quick reply" ] , b [ class "standout" ] [ text " (English please!) " ] @@ -66,5 +81,4 @@ view model = ] , submitButton "Submit" model.state True ] - ] - ] + ] ] diff --git a/lib/VNWeb/Discussions/Thread.pm b/lib/VNWeb/Discussions/Thread.pm index a5aeb8bd..7132f099 100644 --- a/lib/VNWeb/Discussions/Thread.pm +++ b/lib/VNWeb/Discussions/Thread.pm @@ -30,12 +30,16 @@ elm_form 'DiscussionsPoll' => $POLL_OUT, $POLL_IN; -my $REPLY_IN = form_compile any => { +my $REPLY = { tid => { id => 1 }, - msg => { maxlength => 32768 } + old => { _when => 'out', anybool => 1 }, + msg => { _when => 'in', maxlength => 32768 } }; -elm_form 'DiscussionsReply' => undef, $REPLY_IN; +my $REPLY_IN = form_compile in => $REPLY; +my $REPLY_OUT = form_compile out => $REPLY; + +elm_form 'DiscussionsReply' => $REPLY_OUT, $REPLY_IN; @@ -103,10 +107,10 @@ sub posts_ { sub reply_ { - my($t, $page) = @_; + my($t, $posts, $page) = @_; return if $t->{count} > $page*25; if(can_edit t => $t) { - elm_ 'Discussions.Reply' => undef, $t->{id}*1; + elm_ 'Discussions.Reply' => $REPLY_OUT, { tid => $t->{id}, old => $posts->[$#$posts]{date} < time-182*24*3600 }; } else { div_ class => 'mainbox', sub { h1_ 'Reply'; @@ -164,7 +168,7 @@ TUWF::get qr{/$RE{tid}(?:/$RE{num})?}, sub { options => $poll_options } if $t->{poll_question}; posts_ $t, $posts, $page; - reply_ $t, $page; + reply_ $t, $posts, $page; } }; |