Skip to content

feat: make channel lists follow role preview, add preview helpers - #208

Closed
GalaxyAkiii wants to merge 1 commit into
stoatchat:mainfrom
GalaxyAkiii:feat/preview-helpers
Closed

GalaxyAkiii wants to merge 1 commit into
stoatchat:mainfrom
GalaxyAkiii:feat/preview-helpers

Conversation

@GalaxyAkiii

Copy link
Copy Markdown
Member

Follow-up to #202. Moves more of the role preview into stoat.js, so clients using the normal server and channel getters respect the preview without checking for it themselves. Also fixes previewing on current main, which #206 broke.

Changes

  • Server:
    • channels only lists channels the previewed roles can see. Nothing changes when not previewing.
    • Since they build on channels, defaultChannel, unread and mentions go back to their pre-feat: add role preview to permission calculation #202 versions.
    • Adds readOnly, true while changes to the server are blocked (currently only while previewing).
    • Adds hasOwnerPrivileges, owner status that a preview suspends.
    • Adds canPreviewRole(roleId?), whether we can preview a role (or Everyone), judged by our real roles rather than the active preview. This replaces a rank check that was duplicated in two places in for-web.
  • Channel:
    • Adds isVisible, whether we can see the channel, taking any preview into account.
  • calculatePermission:
    • feat: add dispose method to the client #206 added an early return 0n when there's no user. The preview stand-in member has no user, so every permission came out as 0 while previewing. It now only returns early when no member was passed in.

How was this PR tested?

Checklist:

  • I have carefully read the contributing guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR
  • I have confirmed that any new dependencies are strictly necessary
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code

Please declare, if any, LLM usage involved in creating this PR

None

@Dadadah

Dadadah commented Nov 30, 2026

Copy link
Copy Markdown
Member

This library is no longer backing for-web. If your change is needed on for-web, please make the change in for-web. We'll be converting this library to a bot-only library with time. If your pr will still help with that, please reopen it with that in mind. Role preview code should probably be moved into for-web, as I don't see much of a use for it in a bot library.

@Dadadah Dadadah closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants