Show sorted field on the long list by default
This commit is contained in:
parent
3207fcff1b
commit
9420cb56f8
@ -22,10 +22,11 @@ namespace PluralKit.Bot
|
||||
if (target == null) throw Errors.NoSystemError;
|
||||
ctx.CheckSystemPrivacy(target, target.MemberListPrivacy);
|
||||
|
||||
// GetRendererFor must be called before GetOptions as it consumes a potential positional full argument that'd otherwise land in the filter
|
||||
var renderer = GetRendererFor(ctx);
|
||||
// Must match full before calling the other flag parsers to make sure we consume the token before trying to match search terms, etc
|
||||
var isFull = ctx.Match("f", "full", "big", "details", "long") || ctx.MatchFlag("f", "full");
|
||||
var opts = GetOptions(ctx, target);
|
||||
|
||||
var renderer = GetRendererFor(ctx, isFull, opts);
|
||||
|
||||
var members = (await _db.Execute(c => opts.Execute(c, target, ctx.LookupContextFor(target)))).ToList();
|
||||
await ctx.Paginate(
|
||||
members.ToAsyncEnumerable(),
|
||||
@ -62,11 +63,10 @@ namespace PluralKit.Bot
|
||||
return opts;
|
||||
}
|
||||
|
||||
private IListRenderer GetRendererFor(Context ctx)
|
||||
private IListRenderer GetRendererFor(Context ctx, bool isLongList, SortFilterOptions opts)
|
||||
{
|
||||
var longList = ctx.Match("f", "full", "big", "details", "long") || ctx.MatchFlag("f", "full");
|
||||
if (longList)
|
||||
return new LongRenderer(LongRenderer.MemberFields.FromFlags(ctx));
|
||||
if (isLongList)
|
||||
return new LongRenderer(LongRenderer.MemberFields.FromFlags(ctx, opts));
|
||||
return new ShortRenderer();
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,16 @@ namespace PluralKit.Bot
|
||||
public bool ShowLastSwitch = false;
|
||||
public bool ShowLastMessage = false;
|
||||
|
||||
public static MemberFields FromFlags(Context ctx)
|
||||
public static MemberFields FromFlags(Context ctx, SortFilterOptions opts)
|
||||
{
|
||||
var def = new MemberFields();
|
||||
var def = new MemberFields
|
||||
{
|
||||
// Add some defaults depending on sort order
|
||||
ShowLastMessage = opts.SortProperty == SortProperty.LastMessage,
|
||||
ShowLastSwitch = opts.SortProperty == SortProperty.LastSwitch,
|
||||
ShowMessageCount = opts.SortProperty == SortProperty.MessageCount
|
||||
};
|
||||
|
||||
if (ctx.MatchFlag("with-last-switch", "with-last-fronted", "with-last-front", "wls", "wlf"))
|
||||
def.ShowLastSwitch = true;
|
||||
if (ctx.MatchFlag("with-message-count", "wmc"))
|
||||
|
Loading…
Reference in New Issue
Block a user