Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep GraphQL subscriptions active only on a single tab in Web (#1047) #1055

Merged
merged 11 commits into from
Jul 5, 2024

Conversation

SleepySquash
Copy link
Contributor

@SleepySquash SleepySquash commented Jul 1, 2024

Part of #1047

Synopsis

Each new instance of application opens the same subscriptions over and over again, even if those instances all share the same database, which just spams the backend and it isn't good.

Solution

Since drift supports real-time local changes subscription propagating, this renders having to open multiple GraphQL subscriptions useless: one tab may connect to the updates and the other ones can just get those updates via drift subscriptions.

The current idea is to use WebUtils.protect, so that tabs don't invoke subscriptions at the same time at all. After some testing the idea seems to be working. The bugs left to fix:

Checklist

  • Created PR:
    • In draft mode
    • Name contains issue reference
    • Has type and k:: labels applied
  • Before review:
    • Documentation is updated (if required)
    • Tests are updated (if required)
    • Changes conform code style
    • CHANGELOG entry is added (if required)
    • FCM (final commit message) is posted or updated
    • Draft mode is removed
  • Review is completed and changes are approved
    • FCM (final commit message) is approved
  • Before merge:
    • Milestone is set
    • PR's name and description are correct and up-to-date
    • All temporary labels are removed

@SleepySquash SleepySquash added enhancement Improvement of existing features or bugfix k::refactor Refactor changes of existing code labels Jul 1, 2024
@SleepySquash SleepySquash added this to the 0.2.0 milestone Jul 1, 2024
@SleepySquash SleepySquash self-assigned this Jul 1, 2024
@SleepySquash SleepySquash modified the milestones: 0.1.3, 0.2.0 Jul 3, 2024
@SleepySquash
Copy link
Contributor Author

SleepySquash commented Jul 3, 2024

UPD. Moved to #1060

The bugs that should be addressed:

  1. Favourite Chat position changing isn't synced via drift for some reason.
  2. Draft: is blinking rapidly when sending new messages.

@SleepySquash
Copy link
Contributor Author

SleepySquash commented Jul 5, 2024

FCM

Guard GraphQL subscriptions with `WebUtils.protect()` to ensure no simultaneous execution (#1055, #1047)

Additionally:
- fix `ApplicationSettings` being used with default values by awaiting `SettingsRepository.init()`

@SleepySquash SleepySquash marked this pull request as ready for review July 5, 2024 08:36
@SleepySquash SleepySquash merged commit dfef75a into main Jul 5, 2024
24 checks passed
@SleepySquash SleepySquash deleted the 1047-keep-subs-in-one-tab branch July 5, 2024 09:55
github-actions bot added a commit that referenced this pull request Jul 5, 2024
…multaneous execution (#1055, #1047)

Additionally:
- fix `ApplicationSettings` being used with default values by awaiting `SettingsRepository.init()` dfef75a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix k::refactor Refactor changes of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant