Save content settings by muting and unmuting only the pubkeys that changed, so private and non-pubkey mutes survive

This commit is contained in:
Jon Staab 2026-09-25 15:42:28 -07:00
parent 8b8b518602
commit 0ca32a57e2

View file

@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import cx from "classnames" import cx from "classnames"
import {difference} from "@welshman/lib"
import {BlossomServerLists, MuteLists, publish} from "@welshman/app" import {BlossomServerLists, MuteLists, publish} from "@welshman/app"
import NotesMinimalistic from "@assets/icons/notes-minimalistic.svg?dataurl" import NotesMinimalistic from "@assets/icons/notes-minimalistic.svg?dataurl"
import Accessibility from "@assets/icons/accessibility.svg?dataurl" import Accessibility from "@assets/icons/accessibility.svg?dataurl"
@ -46,9 +47,19 @@
try { try {
await publishSettings($settings) await publishSettings($settings)
await $muteLists const previous = $userMuteList?.pubkeys() ?? []
.setMutes({publicTags: mutedPubkeys.map(pubkey => ["p", pubkey])}) const added = difference(mutedPubkeys, previous)
.then(publish) const removed = difference(previous, mutedPubkeys)
// Private and non-pubkey mutes aren't shown here, so only the pubkeys the user changed are touched.
if (added.length > 0 || removed.length > 0) {
await $muteLists
.update(writer => {
added.forEach(pubkey => writer.mutePublicly(pubkey))
removed.forEach(pubkey => writer.unmute(pubkey))
})
.then(publish)
}
await $blossomServerLists.setUrls($state.snapshot(blossomServers)).then(publish) await $blossomServerLists.setUrls($state.snapshot(blossomServers)).then(publish)