mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-30 17:32:26 +00:00
Merge pull request #1266 from PR0M3TH3AN/codex/add-seed-only-condition-detection
Show seeded-moderator-only indicator in moderation settings
This commit is contained in:
4 files changed
+61
-1
No files matched your search
@@ -304,6 +304,14 @@
|
||||
<dd id="profileModerationTrustedReportCount" class="font-semibold text-text">0</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p
|
||||
id="profileModerationSeedOnlyIndicator"
|
||||
class="mt-2 flex items-center gap-1 text-xs text-warning-strong"
|
||||
hidden
|
||||
>
|
||||
<span aria-hidden="true">●</span>
|
||||
<span>Seeded moderators only</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
|
||||
@@ -497,6 +497,7 @@ export class ModerationService {
|
||||
this.trustedMuteLists = new Map();
|
||||
this.trustedMutedAuthors = new Map();
|
||||
this.trustedMuteSubscriptions = new Map();
|
||||
this.trustedSeedOnly = false;
|
||||
|
||||
this.emitter = new SimpleEventEmitter((message, error) => {
|
||||
try {
|
||||
@@ -549,6 +550,35 @@ export class ModerationService {
|
||||
return merged;
|
||||
}
|
||||
|
||||
computeTrustedSeedOnly() {
|
||||
const trustedContacts =
|
||||
this.trustedContacts instanceof Set ? this.trustedContacts : new Set();
|
||||
const trustedSeedContacts =
|
||||
this.trustedSeedContacts instanceof Set ? this.trustedSeedContacts : new Set();
|
||||
|
||||
if (!trustedSeedContacts.size || trustedContacts.size !== trustedSeedContacts.size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const value of trustedContacts) {
|
||||
if (!trustedSeedContacts.has(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
updateTrustedSeedOnlyStatus() {
|
||||
const nextValue = this.computeTrustedSeedOnly();
|
||||
if (nextValue === this.trustedSeedOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.trustedSeedOnly = nextValue;
|
||||
this.emit("trusted-seed-only", { seedOnly: nextValue });
|
||||
}
|
||||
|
||||
rebuildTrustedContacts(nextContacts = new Set(), { previous = null } = {}) {
|
||||
const sanitized = new Set();
|
||||
|
||||
@@ -580,6 +610,7 @@ export class ModerationService {
|
||||
const seededNext = this.mergeSeedsIntoSet(sanitized);
|
||||
this.trustedContacts = seededNext;
|
||||
|
||||
this.updateTrustedSeedOnlyStatus();
|
||||
this.emit("contacts", { size: seededNext.size });
|
||||
this.recomputeAllSummaries();
|
||||
this.reconcileTrustedMuteSubscriptions(previousContacts, seededNext);
|
||||
@@ -681,6 +712,10 @@ export class ModerationService {
|
||||
this.rebuildTrustedContacts(this.viewerContacts, { previous: previousContacts });
|
||||
}
|
||||
|
||||
isTrustedSeedOnly() {
|
||||
return this.trustedSeedOnly === true;
|
||||
}
|
||||
|
||||
logThresholdTransitions({
|
||||
eventId = "",
|
||||
reportType = "",
|
||||
|
||||
@@ -117,6 +117,9 @@ export async function bootstrapTrustedSeeds() {
|
||||
});
|
||||
devLogger.info(`[trustBootstrap] Applying ${seeds.size} trusted seeds`, Array.from(seeds));
|
||||
moderationService.setTrustedSeeds(seeds);
|
||||
if (typeof moderationService.updateTrustedSeedOnlyStatus === "function") {
|
||||
moderationService.updateTrustedSeedOnlyStatus();
|
||||
}
|
||||
if (
|
||||
moderationService &&
|
||||
typeof moderationService.recomputeAllSummaries === "function"
|
||||
|
||||
@@ -1421,6 +1421,8 @@ export class ProfileModalController {
|
||||
document.getElementById("profileModerationTrustedMuteCount") || null;
|
||||
this.moderationTrustedReportCount =
|
||||
document.getElementById("profileModerationTrustedReportCount") || null;
|
||||
this.moderationSeedOnlyIndicator =
|
||||
document.getElementById("profileModerationSeedOnlyIndicator") || null;
|
||||
this.moderationHideControlsGroup =
|
||||
this.moderationSettingsCard?.querySelector(
|
||||
"[data-role=\"trusted-hide-controls\"]",
|
||||
@@ -7140,6 +7142,7 @@ export class ProfileModalController {
|
||||
trustedContactsCount: 0,
|
||||
trustedMuteContributors: 0,
|
||||
trustedReportContributors: 0,
|
||||
trustedSeedOnly: false,
|
||||
};
|
||||
|
||||
const service = this.moderationService;
|
||||
@@ -7147,6 +7150,12 @@ export class ProfileModalController {
|
||||
return summary;
|
||||
}
|
||||
|
||||
if (typeof service.isTrustedSeedOnly === "function") {
|
||||
summary.trustedSeedOnly = service.isTrustedSeedOnly();
|
||||
} else if (typeof service.trustedSeedOnly === "boolean") {
|
||||
summary.trustedSeedOnly = service.trustedSeedOnly;
|
||||
}
|
||||
|
||||
const trustedContacts =
|
||||
service.trustedContacts instanceof Set
|
||||
? service.trustedContacts
|
||||
@@ -7225,7 +7234,8 @@ export class ProfileModalController {
|
||||
if (
|
||||
!(this.moderationTrustedContactsCount instanceof HTMLElement) &&
|
||||
!(this.moderationTrustedMuteCount instanceof HTMLElement) &&
|
||||
!(this.moderationTrustedReportCount instanceof HTMLElement)
|
||||
!(this.moderationTrustedReportCount instanceof HTMLElement) &&
|
||||
!(this.moderationSeedOnlyIndicator instanceof HTMLElement)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -7249,6 +7259,10 @@ export class ProfileModalController {
|
||||
summary.trustedReportContributors,
|
||||
);
|
||||
}
|
||||
|
||||
if (this.moderationSeedOnlyIndicator instanceof HTMLElement) {
|
||||
this.moderationSeedOnlyIndicator.hidden = !summary.trustedSeedOnly;
|
||||
}
|
||||
}
|
||||
|
||||
async handleModerationSettingsSave() {
|
||||
|
||||
Reference in new issue
Block a user