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;
|
if (target == null) throw Errors.NoSystemError;
|
||||||
ctx.CheckSystemPrivacy(target, target.MemberListPrivacy);
|
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
|
// Must match full before calling the other flag parsers to make sure we consume the token before trying to match search terms, etc
|
||||||
var renderer = GetRendererFor(ctx);
|
var isFull = ctx.Match("f", "full", "big", "details", "long") || ctx.MatchFlag("f", "full");
|
||||||
var opts = GetOptions(ctx, target);
|
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();
|
var members = (await _db.Execute(c => opts.Execute(c, target, ctx.LookupContextFor(target)))).ToList();
|
||||||
await ctx.Paginate(
|
await ctx.Paginate(
|
||||||
members.ToAsyncEnumerable(),
|
members.ToAsyncEnumerable(),
|
||||||
@ -62,11 +63,10 @@ namespace PluralKit.Bot
|
|||||||
return opts;
|
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 (isLongList)
|
||||||
if (longList)
|
return new LongRenderer(LongRenderer.MemberFields.FromFlags(ctx, opts));
|
||||||
return new LongRenderer(LongRenderer.MemberFields.FromFlags(ctx));
|
|
||||||
return new ShortRenderer();
|
return new ShortRenderer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,16 @@ namespace PluralKit.Bot
|
|||||||
public bool ShowLastSwitch = false;
|
public bool ShowLastSwitch = false;
|
||||||
public bool ShowLastMessage = 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"))
|
if (ctx.MatchFlag("with-last-switch", "with-last-fronted", "with-last-front", "wls", "wlf"))
|
||||||
def.ShowLastSwitch = true;
|
def.ShowLastSwitch = true;
|
||||||
if (ctx.MatchFlag("with-message-count", "wmc"))
|
if (ctx.MatchFlag("with-message-count", "wmc"))
|
||||||
|
Loading…
Reference in New Issue
Block a user