Skip to content

refactor(mute)!: use muted stream as source of truth instead of relationships model#1391

Merged
Taewa merged 2 commits intodevfrom
refactor/1382-use-muted-user-stream
Feb 27, 2026
Merged

refactor(mute)!: use muted stream as source of truth instead of relationships model#1391
Taewa merged 2 commits intodevfrom
refactor/1382-use-muted-user-stream

Conversation

@Taewa
Copy link
Collaborator

@Taewa Taewa commented Feb 25, 2026

NOTE: NEXT_PUBLIC_DB_VERSION is required in deployment

  • Removed the muted field from UserRelationshipsModel, its schema, and the NexusUserRelationship type
  • Refactored LocalMuteService to use the muted user stream (UserStreamTypes.MUTED) as the single source of truth instead of storing mute state on the relationships model
  • Bumped DB version from 2 to 3 (schema migration for removed column)
  • Updated all tests across 13 files to reflect the new stream-based mute approach

#1382

@Taewa Taewa requested a review from tipogi February 25, 2026 16:55
@Taewa Taewa self-assigned this Feb 25, 2026
@Taewa Taewa requested a review from afterburn February 25, 2026 16:56
@Taewa Taewa added this to the Q1 - 2026 milestone Feb 25, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

Refactored the muting system to use the muted user stream (UserStreamTypes.MUTED) as the single source of truth instead of storing mute state in the user_relationships table.

Key Changes:

  • Removed muted field from UserRelationshipsModel, schema, and NexusUserRelationship type
  • Simplified LocalMuteService logic - removed database transaction complexity and now directly checks/updates the muted stream
  • Bumped DB version from 2 to 3 to trigger schema migration (database recreation handles column removal)
  • Updated 13 test files to verify stream-based mute state instead of relationship model

Architecture Alignment:
This change aligns with the project's data patterns by using streams as the cache layer (per ADR-0003). The muted stream was already being maintained alongside the relationship field, creating redundancy. This refactor eliminates that duplication and simplifies the codebase.

Confidence Score: 5/5

  • safe to merge - clean refactoring with comprehensive test coverage
  • The refactoring is well-executed with proper test updates across all affected areas. DB version bump ensures safe migration via database recreation. The simplified logic removes transaction complexity while maintaining idempotency. The muted stream was already being used by the UI (useMutedUsers hook), so this change eliminates redundancy rather than introducing new behavior.
  • No files require special attention

Important Files Changed

Filename Overview
.env.example bumped DB version from 2 to 3 for schema migration
src/libs/env/env.ts updated default DB version from 2 to 3
src/core/models/user/relationships/userRelationships.schema.ts removed muted field from schema and Dexie index definition
src/core/models/user/relationships/userRelationships.ts removed muted property from model class
src/core/services/nexus/nexus.types.ts removed muted field from NexusUserRelationship type
src/core/services/local/mute/mute.ts refactored to use muted user stream as source of truth instead of relationships model; simplified logic removing transaction complexity

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Mute/Unmute Request] --> B{LocalMuteService}
    B --> C[Check Current Stream State]
    C --> D{Already in desired state?}
    D -->|Yes| E[Return Early - Idempotent]
    D -->|No| F[Update Muted User Stream]
    F --> G[UserStreamTypes.MUTED]
    G -->|Mute| H[prependToStream]
    G -->|Unmute| I[removeFromStream]
    H --> J[Clear Post Stream Queue]
    I --> J
    J --> K[Complete]
    
    style G fill:#e1f5ff
    style B fill:#fff4e6
    style D fill:#f0f0f0
Loading

Last reviewed commit: 5305396

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

🚀 Preview Deployment

URL: https://franky-preview-pr-1391-fzxmjul7ya-oa.a.run.app

franky-preview-pr-1391dbd956b

Copy link
Collaborator

@tipogi tipogi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, few comments

@tipogi tipogi requested a review from secondl1ght February 26, 2026 06:00
@Taewa Taewa changed the title refactor(mute): use muted stream as source of truth instead of relationships model refactor(mute)!: use muted stream as source of truth instead of relationships model Feb 26, 2026
@tipogi tipogi self-requested a review February 26, 2026 15:19
@Taewa Taewa force-pushed the refactor/1382-use-muted-user-stream branch from d76ddc8 to dbd956b Compare February 27, 2026 07:08
@aintnostressin
Copy link

Hi @Taewa , do you plan to remove dependency on nexus muted user stream ?
We got mute removal in nexus prepared.

@ok300 ok300 mentioned this pull request Feb 27, 2026
3 tasks
@Taewa Taewa merged commit dc835a6 into dev Feb 27, 2026
8 checks passed
@Taewa Taewa deleted the refactor/1382-use-muted-user-stream branch February 27, 2026 08:10
@secondl1ght
Copy link
Member

@Taewa it looks like this didn't get reviewed again after you added more commits/force pushed?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants