@@ -28,6 +28,7 @@ import 'presence.dart';
2828import 'realm.dart' ;
2929import 'recent_dm_conversations.dart' ;
3030import 'recent_senders.dart' ;
31+ import 'server_support.dart' ;
3132import 'channel.dart' ;
3233import 'saved_snippet.dart' ;
3334import 'settings.dart' ;
@@ -208,7 +209,7 @@ abstract class GlobalStore extends ChangeNotifier {
208209 assert (account != null ); // doLoadPerAccount would have thrown AccountNotFoundException
209210 final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
210211 switch (e) {
211- case _ServerVersionUnsupportedException ():
212+ case ServerVersionUnsupportedException ():
212213 reportErrorToUserModally (
213214 zulipLocalizations.errorCouldNotConnectTitle,
214215 message: zulipLocalizations.errorServerVersionUnsupportedMessage (
@@ -1026,9 +1027,9 @@ class UpdateMachine {
10261027 try {
10271028 initialSnapshot = await _registerQueueWithRetry (connection,
10281029 stopAndThrowIfNoAccount: stopAndThrowIfNoAccount);
1029- } on _ServerVersionUnsupportedException catch (e) {
1030+ } on ServerVersionUnsupportedException catch (e) {
10301031 // `!` is OK because _registerQueueWithRetry would have thrown a
1031- // not-_ServerVersionUnsupportedException if no account
1032+ // not-ServerVersionUnsupportedException if no account
10321033 final account = globalStore.getAccount (accountId)! ;
10331034 if (! e.data.matchesAccount (account)) {
10341035 await globalStore.updateZulipVersionData (accountId, e.data);
@@ -1094,7 +1095,7 @@ class UpdateMachine {
10941095 case MalformedServerResponseException ()
10951096 when (zulipVersionData = ZulipVersionData .fromMalformedServerResponseException (e))
10961097 ? .isUnsupported == true :
1097- throw _ServerVersionUnsupportedException (zulipVersionData! );
1098+ throw ServerVersionUnsupportedException (zulipVersionData! );
10981099 case HttpException (httpStatus: 401 ):
10991100 // We cannot recover from this error through retrying.
11001101 // Leave it to [GlobalStore.loadPerAccount].
@@ -1114,7 +1115,7 @@ class UpdateMachine {
11141115 stopAndThrowIfNoAccount ();
11151116 final zulipVersionData = ZulipVersionData .fromInitialSnapshot (result);
11161117 if (zulipVersionData.isUnsupported) {
1117- throw _ServerVersionUnsupportedException (zulipVersionData);
1118+ throw ServerVersionUnsupportedException (zulipVersionData);
11181119 }
11191120 return result;
11201121 }
@@ -1529,58 +1530,6 @@ class UpdateMachine {
15291530 String toString () => '${objectRuntimeType (this , 'UpdateMachine' )}#${shortHash (this )}' ;
15301531}
15311532
1532- /// The fields 'zulip_version', 'zulip_merge_base', and 'zulip_feature_level'
1533- /// from a /register response.
1534- class ZulipVersionData {
1535- const ZulipVersionData ({
1536- required this .zulipVersion,
1537- required this .zulipMergeBase,
1538- required this .zulipFeatureLevel,
1539- });
1540-
1541- factory ZulipVersionData .fromInitialSnapshot (InitialSnapshot initialSnapshot) =>
1542- ZulipVersionData (
1543- zulipVersion: initialSnapshot.zulipVersion,
1544- zulipMergeBase: initialSnapshot.zulipMergeBase,
1545- zulipFeatureLevel: initialSnapshot.zulipFeatureLevel);
1546-
1547- /// Make a [ZulipVersionData] from a [MalformedServerResponseException] ,
1548- /// if the body was readable/valid JSON and contained the data, else null.
1549- ///
1550- /// If there's a zulip_version but no zulip_feature_level,
1551- /// we infer it's indeed a Zulip server,
1552- /// just an ancient one before feature levels were introduced in Zulip 3.0,
1553- /// and we set 0 for zulipFeatureLevel.
1554- static ZulipVersionData ? fromMalformedServerResponseException (MalformedServerResponseException e) {
1555- try {
1556- final data = e.data! ;
1557- return ZulipVersionData (
1558- zulipVersion: data['zulip_version' ] as String ,
1559- zulipMergeBase: data['zulip_merge_base' ] as String ? ,
1560- zulipFeatureLevel: data['zulip_feature_level' ] as int ? ?? 0 );
1561- } catch (inner) {
1562- return null ;
1563- }
1564- }
1565-
1566- final String zulipVersion;
1567- final String ? zulipMergeBase;
1568- final int zulipFeatureLevel;
1569-
1570- bool matchesAccount (Account account) =>
1571- zulipVersion == account.zulipVersion
1572- && zulipMergeBase == account.zulipMergeBase
1573- && zulipFeatureLevel == account.zulipFeatureLevel;
1574-
1575- bool get isUnsupported => zulipFeatureLevel < kMinSupportedZulipFeatureLevel;
1576- }
1577-
1578- class _ServerVersionUnsupportedException implements Exception {
1579- final ZulipVersionData data;
1580-
1581- _ServerVersionUnsupportedException (this .data);
1582- }
1583-
15841533class _EventHandlingException implements Exception {
15851534 final Object cause;
15861535 final Event event;
0 commit comments