Fix Claude weekly usage display
This commit is contained in:
@@ -170,8 +170,16 @@ BarWidget {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rateLimitLabelIsWeekly(label) {
|
||||||
|
var text = String(label || "").toLowerCase()
|
||||||
|
return text.indexOf("week") >= 0 || text.indexOf("7-day") >= 0 || text.indexOf("seven_day") >= 0
|
||||||
|
}
|
||||||
|
|
||||||
function usagePercent(provider) {
|
function usagePercent(provider) {
|
||||||
if (!provider) return -1
|
if (!provider) return -1
|
||||||
|
var weekly = weeklyUsage(provider)
|
||||||
|
if (weekly.percent >= 0) return weekly.percent
|
||||||
|
|
||||||
var values = []
|
var values = []
|
||||||
if (provider.rateLimitPercent >= 0) values.push(provider.rateLimitPercent)
|
if (provider.rateLimitPercent >= 0) values.push(provider.rateLimitPercent)
|
||||||
if (provider.secondaryRateLimitPercent >= 0) values.push(provider.secondaryRateLimitPercent)
|
if (provider.secondaryRateLimitPercent >= 0) values.push(provider.secondaryRateLimitPercent)
|
||||||
@@ -186,9 +194,9 @@ BarWidget {
|
|||||||
|
|
||||||
function weeklyUsage(provider) {
|
function weeklyUsage(provider) {
|
||||||
if (!provider) return ({ percent: -1, resetAt: "", label: "" })
|
if (!provider) return ({ percent: -1, resetAt: "", label: "" })
|
||||||
if (String(provider.rateLimitLabel || "").toLowerCase().indexOf("week") >= 0)
|
if (root.rateLimitLabelIsWeekly(provider.rateLimitLabel))
|
||||||
return { percent: provider.rateLimitPercent, resetAt: provider.rateLimitResetAt, label: provider.rateLimitLabel }
|
return { percent: provider.rateLimitPercent, resetAt: provider.rateLimitResetAt, label: provider.rateLimitLabel }
|
||||||
if (String(provider.secondaryRateLimitLabel || "").toLowerCase().indexOf("week") >= 0)
|
if (root.rateLimitLabelIsWeekly(provider.secondaryRateLimitLabel))
|
||||||
return { percent: provider.secondaryRateLimitPercent, resetAt: provider.secondaryRateLimitResetAt, label: provider.secondaryRateLimitLabel }
|
return { percent: provider.secondaryRateLimitPercent, resetAt: provider.secondaryRateLimitResetAt, label: provider.secondaryRateLimitLabel }
|
||||||
return ({ percent: -1, resetAt: "", label: "" })
|
return ({ percent: -1, resetAt: "", label: "" })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ Item {
|
|||||||
property string usageStatusText: ""
|
property string usageStatusText: ""
|
||||||
|
|
||||||
property real rateLimitPercent: -1
|
property real rateLimitPercent: -1
|
||||||
property string rateLimitLabel: "Weekly (7-day)"
|
property string rateLimitLabel: "Session (5-hour)"
|
||||||
property string rateLimitResetAt: ""
|
property string rateLimitResetAt: ""
|
||||||
property real secondaryRateLimitPercent: -1
|
property real secondaryRateLimitPercent: -1
|
||||||
property string secondaryRateLimitLabel: "Session (5-hour)"
|
property string secondaryRateLimitLabel: "Weekly (7-day)"
|
||||||
property string secondaryRateLimitResetAt: ""
|
property string secondaryRateLimitResetAt: ""
|
||||||
|
|
||||||
property int todayPrompts: 0
|
property int todayPrompts: 0
|
||||||
@@ -284,10 +284,10 @@ Item {
|
|||||||
function clearAuthoritativeRateLimits() {
|
function clearAuthoritativeRateLimits() {
|
||||||
root.hasAuthoritativeRateLimit = false;
|
root.hasAuthoritativeRateLimit = false;
|
||||||
root.rateLimitPercent = -1;
|
root.rateLimitPercent = -1;
|
||||||
root.rateLimitLabel = "Weekly (7-day)";
|
root.rateLimitLabel = "Session (5-hour)";
|
||||||
root.rateLimitResetAt = "";
|
root.rateLimitResetAt = "";
|
||||||
root.secondaryRateLimitPercent = -1;
|
root.secondaryRateLimitPercent = -1;
|
||||||
root.secondaryRateLimitLabel = "Session (5-hour)";
|
root.secondaryRateLimitLabel = "Weekly (7-day)";
|
||||||
root.secondaryRateLimitResetAt = "";
|
root.secondaryRateLimitResetAt = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,29 +360,27 @@ Item {
|
|||||||
|
|
||||||
root.hasAuthoritativeRateLimit = true;
|
root.hasAuthoritativeRateLimit = true;
|
||||||
root.rateLimitPercent = -1;
|
root.rateLimitPercent = -1;
|
||||||
root.rateLimitLabel = "Weekly (7-day)";
|
root.rateLimitLabel = "Session (5-hour)";
|
||||||
root.rateLimitResetAt = "";
|
root.rateLimitResetAt = "";
|
||||||
root.secondaryRateLimitPercent = -1;
|
root.secondaryRateLimitPercent = -1;
|
||||||
root.secondaryRateLimitLabel = "Session (5-hour)";
|
root.secondaryRateLimitLabel = "Weekly (7-day)";
|
||||||
root.secondaryRateLimitResetAt = "";
|
root.secondaryRateLimitResetAt = "";
|
||||||
|
|
||||||
if (weeklyNorm >= 0)
|
|
||||||
root.rateLimitPercent = weeklyNorm;
|
|
||||||
if (sessionNorm >= 0)
|
if (sessionNorm >= 0)
|
||||||
root.secondaryRateLimitPercent = sessionNorm;
|
|
||||||
if (weeklyReset !== null && weeklyReset !== undefined)
|
|
||||||
root.rateLimitResetAt = root.normalizeResetAt(weeklyReset);
|
|
||||||
if (sessionReset !== null && sessionReset !== undefined)
|
|
||||||
root.secondaryRateLimitResetAt = root.normalizeResetAt(sessionReset);
|
|
||||||
|
|
||||||
if (root.rateLimitPercent < 0 && sessionNorm >= 0) {
|
|
||||||
root.rateLimitPercent = sessionNorm;
|
root.rateLimitPercent = sessionNorm;
|
||||||
root.rateLimitLabel = root.secondaryRateLimitLabel;
|
if (weeklyNorm >= 0)
|
||||||
root.rateLimitResetAt = root.secondaryRateLimitResetAt;
|
root.secondaryRateLimitPercent = weeklyNorm;
|
||||||
}
|
if (sessionReset !== null && sessionReset !== undefined)
|
||||||
|
root.rateLimitResetAt = root.normalizeResetAt(sessionReset);
|
||||||
|
if (weeklyReset !== null && weeklyReset !== undefined)
|
||||||
|
root.secondaryRateLimitResetAt = root.normalizeResetAt(weeklyReset);
|
||||||
|
|
||||||
if (sourceLabel)
|
if (sourceLabel) {
|
||||||
root.rateLimitLabel = root.rateLimitLabel + " (" + sourceLabel + ")";
|
if (root.secondaryRateLimitPercent >= 0)
|
||||||
|
root.secondaryRateLimitLabel = root.secondaryRateLimitLabel + " (" + sourceLabel + ")";
|
||||||
|
else if (root.rateLimitPercent >= 0)
|
||||||
|
root.rateLimitLabel = root.rateLimitLabel + " (" + sourceLabel + ")";
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user