wxkwxk666 asked for two things on the Usage page. First, a provider switched off should still show its accounts, at the bottom and folded, so they can still be checked in each day. Second, one button should check in every account at once. - provider.OffCheckins (off_checkins.go) lists every account a checkiner reaches whose provider is switched off (Off, not Hidden). Each is a card with no windows. Nothing is read or asked for it. Its check-in result is matched by its own key, not by its name, since two sign-ins can share a name (plugins#254). GET /api/usage/checkins/off serves the list. - The Usage page (plugins/usage) adds a "Switched off · n" line after the cards and the hidden line. It is folded until clicked. Each account shows today's check-in, and a Check in button when it isn't checked in yet. The button uses checkinnow.js's ciNowSend, which POSTs /api/usage/checkin-account. - Check in all, at the head of the allowances, presses every account not checked in today, from the cards and from the switched-off line. It sends one checkin-account request per account, three at a time, shows "Checking in i/n…", then gives the counts (checkinPressSaid). When no account is due, it says so and sends nothing. - Nothing switches a provider back on. The new strings are in zh, zh-TW, ja and de. Plugin files only: app.js is unchanged. - docs/subsystems/provider-plugins.md says all of this. Run, on mote: - TestOffCheckinsListsSwitchedOffAccounts, in the fakeco plugin sandbox: - nothing is listed before the switch-off; - after it, two cards with distinct keys; - a press on one checks in exactly that account; - the provider stays off; - only the pressed card carries a result; - nothing is listed once the provider is switched on. - go test ./internal/provider ./internal/gui, at this commit on origin/main0fda3a1c1: gui ok; provider ok but for TestHostBuildsNoList, red on main already (#6479) - gofmt - go vet for darwin, linux (-tags nogui, ./...) and windows - usage-checkin-all.test.cjs, in Chromium and WebKit, at 900 and 420px, in en, zh, zh-TW, ja and de (20 of 20). It covers: - the line is folded, at the end, with its count; - opening it doesn't scroll; - a row's own press asks for that account only; - Check in all shows 0/2 while held, presses only the two due accounts, and POSTs nothing else (no provider switched on); - a second press asks nothing and says every account is in. - 187 GUI files (the Usage page, panel, tray, settings and their neighbours), at the rebased head on mote: 3080 cases, 104 red in 16 files. Those 16 run again on mote at origin/main5a2d0ff47and at this commit, under the same load: the same 12 files are red on both (checkin-now-account #6029, codex-auto-reset #4790, key-balance-card #6414, menu-scroll #5982, mobile-web #3952, old-webkit #6030, quota-refresh-order #6180, tray-cell-click #5215, usage-cards-hide #6294, usage-fold #4790, usage-hidden-way-back #6295, usage-range-times #6499, filed now). account-eye, i18n-keys, last-page and quota-warm pass on both in that rerun. - That wide run found account-alias and account-eye red on an earlier draft: a fixture answering {} for the new endpoint made the page spread a non-array. The page now takes only an array. Broken by hand: - Without checkinAll's not-due skip, all 20 GUI cases go red. - Without OffCheckins' check-in result (q.Checkin), the Go test goes red at off_checkins_test.go:56. - Matching results by name (WithCheckins), as an earlier draft did, also went red. Not tried: checking in a real switched-off vendor account through the real app. The press is the existing CheckInAccount path, the same one Settings' per-account Check in now already uses.
58 lines
1.8 KiB
Go
58 lines
1.8 KiB
Go
package provider
|
|
|
|
// OffCheckins are the accounts a daily check-in reaches whose provider
|
|
// the user switched off (wxkwxk666 on X: 禁用的供应商也要能签到). The Usage
|
|
// page leaves a switched-off provider's cards out (visibleQuotas), and the
|
|
// daily loop leaves it alone (leftAlone), so these are shown in a folded
|
|
// group of their own, each to be checked in by hand (CheckInAccount),
|
|
// which switches nothing back on.
|
|
//
|
|
// Each is a card with no windows: the provider, its name and icon, the
|
|
// account, and its check-in, found by its own key. No allowance is
|
|
// read and nothing is asked; a provider whose account was removed from
|
|
// magpie (Hidden) is not listed.
|
|
func OffCheckins() []SubscriptionQuota {
|
|
off := map[string]Provider{}
|
|
for _, p := range All() {
|
|
if p.Off && !p.Hidden {
|
|
off[p.ID] = p
|
|
}
|
|
}
|
|
if len(off) == 0 {
|
|
return nil
|
|
}
|
|
var qs []SubscriptionQuota
|
|
seen := map[string]bool{}
|
|
skip := checkinOff()
|
|
for _, c := range checkiners() {
|
|
var st map[string]WorkBuddyCheckin
|
|
for _, a := range c.accounts() {
|
|
p, ok := off[a.provider]
|
|
if !ok || !a.On || a.key == "" || seen[c.by+"\x00"+a.key] {
|
|
continue
|
|
}
|
|
seen[c.by+"\x00"+a.key] = true
|
|
name, icon := p.Name, p.Icon
|
|
if pp, ok := PluginOf(a.provider); ok {
|
|
name, icon = pluginCard(pp)
|
|
}
|
|
if name == "" {
|
|
name = a.provider
|
|
}
|
|
// marked by its own key, not by its name as WithCheckins does
|
|
// a card: two sign-ins can share a name (plugins#254)
|
|
q := SubscriptionQuota{Provider: a.provider, Name: name, Icon: icon, User: a.User, Windows: []QuotaWindow{},
|
|
Checkins: true, CheckinBy: c.by, CheckinKey: a.key, CheckinOff: skip[a.key]}
|
|
if st == nil {
|
|
st = shownCheckins(c.path)
|
|
}
|
|
if r, ok := st[a.key]; ok {
|
|
r.User, r.By = a.User, c.by
|
|
q.Checkin = &r
|
|
}
|
|
qs = append(qs, q)
|
|
}
|
|
}
|
|
return InProviderOrder(qs)
|
|
}
|