Disable scope selection when replying to a direct post

This commit is contained in:
r 2020-06-18 05:02:45 +00:00
parent bd3f9ac966
commit 34c1d087af
3 changed files with 13 additions and 14 deletions

View File

@ -13,7 +13,8 @@ type PostContext struct {
} }
type ReplyContext struct { type ReplyContext struct {
InReplyToID string InReplyToID string
InReplyToName string InReplyToName string
ReplyContent string ReplyContent string
ForceVisibility bool
} }

View File

@ -313,12 +313,9 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
} }
} }
if c.Session.Settings.CopyScope { isDirect := status.Visibility == "direct"
s, err := c.GetStatus(ctx, id) if isDirect || c.Session.Settings.CopyScope {
if err != nil { visibility = status.Visibility
return err
}
visibility = s.Visibility
} else { } else {
visibility = c.Session.Settings.DefaultVisibility visibility = c.Session.Settings.DefaultVisibility
} }
@ -327,9 +324,10 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
DefaultVisibility: visibility, DefaultVisibility: visibility,
Formats: svc.postFormats, Formats: svc.postFormats,
ReplyContext: &model.ReplyContext{ ReplyContext: &model.ReplyContext{
InReplyToID: id, InReplyToID: id,
InReplyToName: status.Account.Acct, InReplyToName: status.Account.Acct,
ReplyContent: content, ReplyContent: content,
ForceVisibility: isDirect,
}, },
DarkMode: c.Session.Settings.DarkMode, DarkMode: c.Session.Settings.DarkMode,
} }
@ -351,7 +349,7 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
idNumbers[statuses[i].ID] = i + 1 idNumbers[statuses[i].ID] = i + 1
statuses[i].IDReplies = replies statuses[i].IDReplies = replies
addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i + 1) addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i+1)
} }
commonData := svc.getCommonData(c, "post by "+status.Account.DisplayName) commonData := svc.getCommonData(c, "post by "+status.Account.DisplayName)

View File

@ -24,7 +24,7 @@
{{end}} {{end}}
<span class="post-form-field"> <span class="post-form-field">
<label for="post-visilibity"> Scope </label> <label for="post-visilibity"> Scope </label>
<select id="post-visilibity" name="visibility"> <select id="post-visilibity" name="visibility" {{if .ReplyContext}}{{if .ReplyContext.ForceVisibility}}disabled{{end}}{{end}}>
<option value="public" {{if eq .DefaultVisibility "public"}}selected{{end}}>Public</option> <option value="public" {{if eq .DefaultVisibility "public"}}selected{{end}}>Public</option>
<option value="unlisted" {{if eq .DefaultVisibility "unlisted"}}selected{{end}}>Unlisted</option> <option value="unlisted" {{if eq .DefaultVisibility "unlisted"}}selected{{end}}>Unlisted</option>
<option value="private" {{if eq .DefaultVisibility "private"}}selected{{end}}>Private</option> <option value="private" {{if eq .DefaultVisibility "private"}}selected{{end}}>Private</option>