feat: web push notifications, image fullscreen, public room browser

- Web Push: push_sw.js service worker + VAPID subscription registered
  on login; Matrix pusher registered pointing to Sygnal on
  https://matrix.m8chat.au/_matrix/push/v1/notify
- Chat: tap image -> fullscreen InteractiveViewer (pinch/zoom)
- Rooms: public room browser via Matrix room directory (FAB + empty state)

Build fixes applied to web_push_service.dart:
  - dart:js_interop_unsafe import added for getProperty on JSObject
  - client.setPusher -> client.postPusher (matrix 0.33.0 API)
  - keyBytes.toJS removed (JSUint8Array already a JS type)
  - register() script URL coerced with .toJS (String -> JSAny)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 06:48:48 +10:00
parent 542a5e5221
commit 1cffe09faf
5 changed files with 262 additions and 3 deletions

View File

@@ -1,15 +1,19 @@
// Version: 2.0.0 | Created: 2026-04-01 | Updated: 2026-04-11
// Version: 2.1.0 | Created: 2026-04-01 | Updated: 2026-04-27
// Riverpod notifier that owns the auth state machine.
//
// WEB SECURITY MODEL: Every visit requires a fresh login. No session
// persistence. Only the Matrix device ID is saved across sessions so
// encryption keys accumulate on one device instead of creating ghosts.
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../../features/auth/data/auth_repository.dart';
import '../../features/auth/domain/auth_failure.dart';
import '../network/matrix_client.dart';
import '../push/web_push_service.dart';
import '../storage/sync_persistence_service.dart';
import 'auth_state.dart';
@@ -51,6 +55,10 @@ class AuthNotifier extends _$AuthNotifier {
try {
ref.read(syncPersistenceServiceProvider).start();
} catch (_) {}
// Register Web Push subscription (fire-and-forget, non-fatal).
final client = ref.read(matrixClientProvider);
unawaited(setupWebPush(client));
} on AuthFailure catch (failure) {
state = AuthState.unauthenticated(failure: failure.userMessage);
}