Skip to content

Commit

Permalink
fix #234: allow copy paste of current status
Browse files Browse the repository at this point in the history
  • Loading branch information
vjousse committed Jun 21, 2024
1 parent 1f48660 commit 6149da2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/View/Account.elm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ accountTimelineView currentUser accountInfo =
let
keyedEntry status =
( extractStatusId status.id
, Lazy.lazy (statusEntryView "account" "status" currentUser) status
, Lazy.lazy (statusEntryView "account" "status" False currentUser) status
)

entries =
Expand Down
4 changes: 2 additions & 2 deletions src/View/Draft.elm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ draftReplyToView draft =
, text ")"
]
]
, div [ class "well" ] [ Lazy.lazy2 statusView "draft" status ]
, div [ class "well" ] [ Lazy.lazy3 statusView "draft" False status ]
]

Editing statusEdit ->
Expand All @@ -196,7 +196,7 @@ draftReplyToView draft =
, text ")"
]
]
, div [ class "well" ] [ Lazy.lazy2 statusView "draft" statusEdit.status ]
, div [ class "well" ] [ Lazy.lazy3 statusView "draft" False statusEdit.status ]
]

_ ->
Expand Down
2 changes: 1 addition & 1 deletion src/View/Notification.elm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ notificationStatusView { context, currentUser, status, notificationAggregate } =

_ ->
text ""
, Lazy.lazy2 statusView context status
, Lazy.lazy3 statusView context False status
, Lazy.lazy3 statusActionsView status currentUser False
]

Expand Down
38 changes: 26 additions & 12 deletions src/View/Status.elm
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,21 @@ statusActionsView status currentUser showApp =
]


statusContentView : String -> Status -> Html Msg
statusContentView context status =
statusContentView : String -> Bool -> Status -> Html Msg
statusContentView context isThreadTarget status =
case status.spoiler_text of
"" ->
div [ class "status-text" ]
[ div [ onClickWithStop <| OpenThread status ] <| formatContentWithEmojis status.content status.mentions status.emojis
[ div
[ onClickWithStop <|
if isThreadTarget then
NoOp

else
OpenThread status
]
<|
formatContentWithEmojis status.content status.mentions status.emojis
, attachmentListView context status
]

Expand All @@ -216,7 +225,12 @@ statusContentView context status =
div [ class "status-text spoiled" ]
[ div
[ class "spoiler"
, onClickWithStop <| OpenThread status
, onClickWithStop <|
if isThreadTarget then
NoOp

else
OpenThread status
]
[ text status.spoiler_text ]
, input [ type_ "checkbox", id statusId, class "spoiler-toggler" ] []
Expand All @@ -228,8 +242,8 @@ statusContentView context status =
]


statusEntryView : String -> String -> CurrentUser -> Status -> Html Msg
statusEntryView context className currentUser status =
statusEntryView : String -> String -> Bool -> CurrentUser -> Status -> Html Msg
statusEntryView context className isThreadTarget currentUser status =
let
nsfwClass =
case status.sensitive of
Expand All @@ -249,13 +263,13 @@ statusEntryView context className currentUser status =
)
in
li liAttributes
[ Lazy.lazy2 statusView context status
, Lazy.lazy3 statusActionsView status currentUser (className == "thread-target")
[ Lazy.lazy3 statusView context isThreadTarget status
, Lazy.lazy3 statusActionsView status currentUser isThreadTarget
]


statusView : String -> Status -> Html Msg
statusView context ({ account, reblog } as status) =
statusView : String -> Bool -> Status -> Html Msg
statusView context isThreadTarget ({ account, reblog } as status) =
let
accountLinkAttributes =
[ href <| "#account/" ++ account.id ]
Expand All @@ -269,7 +283,7 @@ statusView context ({ account, reblog } as status) =
[ text <| " @" ++ account.username ]
, text " boosted"
]
, Lazy.lazy2 statusView context r
, Lazy.lazy3 statusView context isThreadTarget r
]

Nothing ->
Expand All @@ -282,5 +296,5 @@ statusView context ({ account, reblog } as status) =
]
)
]
, Lazy.lazy2 statusContentView context status
, Lazy.lazy3 statusContentView context isThreadTarget status
]
1 change: 1 addition & 0 deletions src/View/Thread.elm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ threadStatuses currentUser thread =
else
""
)
(status == threadStatus)
currentUser
status

Expand Down
4 changes: 2 additions & 2 deletions src/View/Timeline.elm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ timelineViewInfiniteScroll : CurrentUser -> Timeline Status -> ScrollElement ->
timelineViewInfiniteScroll currentUser timeline scrollElement =
let
keyedEntry status =
( extractStatusId status.id, statusEntryView timeline.id "" currentUser status )
( extractStatusId status.id, statusEntryView timeline.id "" False currentUser status )

entries =
List.map keyedEntry timeline.entries
Expand All @@ -62,7 +62,7 @@ timelineView : CurrentUser -> Timeline Status -> Html Msg
timelineView currentUser timeline =
let
keyedEntry status =
( extractStatusId status.id, statusEntryView timeline.id "" currentUser status )
( extractStatusId status.id, statusEntryView timeline.id "" False currentUser status )

entries =
List.map keyedEntry timeline.entries
Expand Down

0 comments on commit 6149da2

Please sign in to comment.