🐛 Dozens of bug fixes

This commit is contained in:
2025-07-18 18:57:16 +08:00
parent e6c58b7b63
commit 3a4faac8cb
10 changed files with 48 additions and 33 deletions

View File

@@ -26,6 +26,7 @@ sealed class WebSocketPacket with _$WebSocketPacket {
const factory WebSocketPacket({
required String type,
required Map<String, dynamic>? data,
String? endpoint,
String? errorMessage,
}) = _WebSocketPacket;

View File

@@ -379,7 +379,7 @@ as String,
/// @nodoc
mixin _$WebSocketPacket implements DiagnosticableTreeMixin {
String get type; Map<String, dynamic>? get data; String? get errorMessage;
String get type; Map<String, dynamic>? get data; String? get endpoint; String? get errorMessage;
/// Create a copy of WebSocketPacket
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -393,21 +393,21 @@ $WebSocketPacketCopyWith<WebSocketPacket> get copyWith => _$WebSocketPacketCopyW
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'WebSocketPacket'))
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('errorMessage', errorMessage));
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('endpoint', endpoint))..add(DiagnosticsProperty('errorMessage', errorMessage));
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.endpoint, endpoint) || other.endpoint == endpoint)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(data),errorMessage);
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(data),endpoint,errorMessage);
@override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
return 'WebSocketPacket(type: $type, data: $data, errorMessage: $errorMessage)';
return 'WebSocketPacket(type: $type, data: $data, endpoint: $endpoint, errorMessage: $errorMessage)';
}
@@ -418,7 +418,7 @@ abstract mixin class $WebSocketPacketCopyWith<$Res> {
factory $WebSocketPacketCopyWith(WebSocketPacket value, $Res Function(WebSocketPacket) _then) = _$WebSocketPacketCopyWithImpl;
@useResult
$Res call({
String type, Map<String, dynamic>? data, String? errorMessage
String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage
});
@@ -435,11 +435,12 @@ class _$WebSocketPacketCopyWithImpl<$Res>
/// Create a copy of WebSocketPacket
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? type = null,Object? data = freezed,Object? errorMessage = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? type = null,Object? data = freezed,Object? endpoint = freezed,Object? errorMessage = freezed,}) {
return _then(_self.copyWith(
type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,endpoint: freezed == endpoint ? _self.endpoint : endpoint // ignore: cast_nullable_to_non_nullable
as String?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
));
}
@@ -522,10 +523,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _WebSocketPacket() when $default != null:
return $default(_that.type,_that.data,_that.errorMessage);case _:
return $default(_that.type,_that.data,_that.endpoint,_that.errorMessage);case _:
return orElse();
}
@@ -543,10 +544,10 @@ return $default(_that.type,_that.data,_that.errorMessage);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage) $default,) {final _that = this;
switch (_that) {
case _WebSocketPacket():
return $default(_that.type,_that.data,_that.errorMessage);}
return $default(_that.type,_that.data,_that.endpoint,_that.errorMessage);}
}
/// A variant of `when` that fallback to returning `null`
///
@@ -560,10 +561,10 @@ return $default(_that.type,_that.data,_that.errorMessage);}
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String type, Map<String, dynamic>? data, String? errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage)? $default,) {final _that = this;
switch (_that) {
case _WebSocketPacket() when $default != null:
return $default(_that.type,_that.data,_that.errorMessage);case _:
return $default(_that.type,_that.data,_that.endpoint,_that.errorMessage);case _:
return null;
}
@@ -575,7 +576,7 @@ return $default(_that.type,_that.data,_that.errorMessage);case _:
@JsonSerializable()
class _WebSocketPacket with DiagnosticableTreeMixin implements WebSocketPacket {
const _WebSocketPacket({required this.type, required final Map<String, dynamic>? data, this.errorMessage}): _data = data;
const _WebSocketPacket({required this.type, required final Map<String, dynamic>? data, this.endpoint, this.errorMessage}): _data = data;
factory _WebSocketPacket.fromJson(Map<String, dynamic> json) => _$WebSocketPacketFromJson(json);
@override final String type;
@@ -588,6 +589,7 @@ class _WebSocketPacket with DiagnosticableTreeMixin implements WebSocketPacket {
return EqualUnmodifiableMapView(value);
}
@override final String? endpoint;
@override final String? errorMessage;
/// Create a copy of WebSocketPacket
@@ -604,21 +606,21 @@ Map<String, dynamic> toJson() {
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'WebSocketPacket'))
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('errorMessage', errorMessage));
..add(DiagnosticsProperty('type', type))..add(DiagnosticsProperty('data', data))..add(DiagnosticsProperty('endpoint', endpoint))..add(DiagnosticsProperty('errorMessage', errorMessage));
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._data, _data)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WebSocketPacket&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._data, _data)&&(identical(other.endpoint, endpoint) || other.endpoint == endpoint)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(_data),errorMessage);
int get hashCode => Object.hash(runtimeType,type,const DeepCollectionEquality().hash(_data),endpoint,errorMessage);
@override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
return 'WebSocketPacket(type: $type, data: $data, errorMessage: $errorMessage)';
return 'WebSocketPacket(type: $type, data: $data, endpoint: $endpoint, errorMessage: $errorMessage)';
}
@@ -629,7 +631,7 @@ abstract mixin class _$WebSocketPacketCopyWith<$Res> implements $WebSocketPacket
factory _$WebSocketPacketCopyWith(_WebSocketPacket value, $Res Function(_WebSocketPacket) _then) = __$WebSocketPacketCopyWithImpl;
@override @useResult
$Res call({
String type, Map<String, dynamic>? data, String? errorMessage
String type, Map<String, dynamic>? data, String? endpoint, String? errorMessage
});
@@ -646,11 +648,12 @@ class __$WebSocketPacketCopyWithImpl<$Res>
/// Create a copy of WebSocketPacket
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? type = null,Object? data = freezed,Object? errorMessage = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? type = null,Object? data = freezed,Object? endpoint = freezed,Object? errorMessage = freezed,}) {
return _then(_WebSocketPacket(
type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,data: freezed == data ? _self._data : data // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,endpoint: freezed == endpoint ? _self.endpoint : endpoint // ignore: cast_nullable_to_non_nullable
as String?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
));
}

View File

@@ -10,6 +10,7 @@ _WebSocketPacket _$WebSocketPacketFromJson(Map<String, dynamic> json) =>
_WebSocketPacket(
type: json['type'] as String,
data: json['data'] as Map<String, dynamic>?,
endpoint: json['endpoint'] as String?,
errorMessage: json['error_message'] as String?,
);
@@ -17,5 +18,6 @@ Map<String, dynamic> _$WebSocketPacketToJson(_WebSocketPacket instance) =>
<String, dynamic>{
'type': instance.type,
'data': instance.data,
'endpoint': instance.endpoint,
'error_message': instance.errorMessage,
};

View File

@@ -6,7 +6,7 @@ part of 'captcha.config.dart';
// RiverpodGenerator
// **************************************************************************
String _$captchaUrlHash() => r'627caa2f2eb020a28a4b138122fe8e99915185f9';
String _$captchaUrlHash() => r'bbed0d18272dd205069642b3c6583ea2eef735d1';
/// See also [captchaUrl].
@ProviderFor(captchaUrl)

View File

@@ -376,7 +376,11 @@ class ChatRoomScreen extends HookConsumerWidget {
final wsState = ref.read(websocketStateProvider.notifier);
wsState.sendMessage(
jsonEncode(
WebSocketPacket(type: 'messages.read', data: {'chat_room_id': id}),
WebSocketPacket(
type: 'messages.read',
data: {'chat_room_id': id},
endpoint: 'DysonNetwork.Sphere',
),
),
);
}
@@ -393,7 +397,11 @@ class ChatRoomScreen extends HookConsumerWidget {
final wsState = ref.read(websocketStateProvider.notifier);
wsState.sendMessage(
jsonEncode(
WebSocketPacket(type: 'messages.typing', data: {'chat_room_id': id}),
WebSocketPacket(
type: 'messages.typing',
data: {'chat_room_id': id},
endpoint: 'DysonNetwork.Sphere',
),
),
);

View File

@@ -160,11 +160,11 @@ class EditPublisherScreen extends HookConsumerWidget {
try {
final client = ref.watch(apiClientProvider);
final resp = await client.request(
name == null
'/sphere${name == null
? currentRealm.value == null
? '/publishers/individual'
: '/publishers/organization/${currentRealm.value!.slug}'
: '/publishers/$name',
: '/publishers/$name'}',
data: {
'name': nameController.text,
'nick': nickController.text,

View File

@@ -175,8 +175,8 @@ Completer<SnCloudFile?> _processUpload(
final client = TusClient(file);
client
.upload(
uri: Uri.parse('$baseUrl/files/tus'),
headers: {'Authorization': 'Bearer $atk'},
uri: Uri.parse('$baseUrl/drive/tus'),
headers: {'Authorization': 'AtField $atk'},
metadata: metadata,
onComplete: (lastResponse) {
final resp = jsonDecode(lastResponse!.headers['x-fileinfo']!);

View File

@@ -110,7 +110,7 @@ Future<void> _putTokenToRemote(
int provider,
) async {
await apiClient.put(
"/notifications/subscription",
"/pusher/notifications/subscription",
data: {"provider": provider, "device_token": token},
);
}

View File

@@ -6,7 +6,7 @@ part of 'account_picker.dart';
// RiverpodGenerator
// **************************************************************************
String _$searchAccountsHash() => r'4923cd06876d04515d95d3c58ee3ea9e05c58e4a';
String _$searchAccountsHash() => r'fa3b8b7d51e14cf40d4116ba0ff0b6955fa0ff54';
/// Copied from Dart SDK
class _SystemHash {

View File

@@ -467,7 +467,7 @@ class ComposeLogic {
final attachment = state.attachments.value[index];
if (attachment.isOnCloud) {
final client = ref.watch(apiClientProvider);
await client.delete('/files/${attachment.data.id}');
await client.delete('/drive/files/${attachment.data.id}');
}
final clone = List.of(state.attachments.value);
clone.removeAt(index);
@@ -530,7 +530,8 @@ class ComposeLogic {
// Prepare API request
final client = ref.watch(apiClientProvider);
final isNewPost = originalPost == null;
final endpoint = isNewPost ? '/posts' : '/posts/${originalPost.id}';
final endpoint =
'/sphere${isNewPost ? '/posts' : '/posts/${originalPost.id}'}';
// Create request payload
final payload = {