mirror of
https://github.com/LinwoodDev/Butterfly.git
synced 2026-03-13 09:20:32 +08:00
Fix opening local files when default storage is set to cloud
This commit is contained in:
@@ -322,9 +322,7 @@ class ButterflyFileSystem {
|
||||
|
||||
Future<void> updatePack(PackAssetLocation location, NoteData newPack) =>
|
||||
buildPackSystem(
|
||||
location.namespace.isEmpty
|
||||
? null
|
||||
: settingsCubit.state.getRemote(location.namespace),
|
||||
settingsCubit.getRemote(location.namespace),
|
||||
).updateFile(location.key, newPack);
|
||||
|
||||
void removeCachedDocumentSystem(ExternalStorage? storage) {
|
||||
|
||||
@@ -256,7 +256,7 @@ class DocumentLoadSuccess extends DocumentLoaded {
|
||||
!absolute &&
|
||||
(location.fileType?.isNote() ?? false) &&
|
||||
(location.remote.isEmpty ||
|
||||
(settingsCubit.state
|
||||
(settingsCubit
|
||||
.getRemote(location.remote)
|
||||
?.hasDocumentCached(location.path) ??
|
||||
false))));
|
||||
|
||||
@@ -1889,9 +1889,8 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
|
||||
|
||||
void exitHideUI() => emit(state.copyWith(hideUi: HideState.visible));
|
||||
|
||||
ExternalStorage? getRemoteStorage() => state.location.remote.isEmpty
|
||||
? null
|
||||
: state.settingsCubit.state.getRemote(state.location.remote);
|
||||
ExternalStorage? getRemoteStorage() =>
|
||||
state.settingsCubit.getRemote(state.location.remote);
|
||||
|
||||
final _savingLock = Lock();
|
||||
|
||||
|
||||
@@ -666,12 +666,13 @@ sealed class ButterflySettings with _$ButterflySettings, LeapSettings {
|
||||
}
|
||||
|
||||
ExternalStorage? getRemote(String? identifier) {
|
||||
if (identifier?.isEmpty ?? true) {
|
||||
if (identifier == null) {
|
||||
return getDefaultRemote();
|
||||
}
|
||||
return connections.firstWhereOrNull(
|
||||
(e) => e.identifier == (identifier ?? defaultRemote),
|
||||
);
|
||||
if (identifier.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return connections.firstWhereOrNull((e) => e.identifier == identifier);
|
||||
}
|
||||
|
||||
bool hasRemote(String identifier) {
|
||||
@@ -1043,9 +1044,7 @@ class SettingsCubit extends Cubit<ButterflySettings>
|
||||
}
|
||||
|
||||
ExternalStorage? getRemote([String? remote]) {
|
||||
return state.connections.firstWhereOrNull(
|
||||
(element) => element.identifier == (remote ?? state.defaultRemote),
|
||||
);
|
||||
return state.getRemote(remote);
|
||||
}
|
||||
|
||||
Future<void> toggleStarred(AssetLocation location) {
|
||||
|
||||
@@ -31,12 +31,11 @@ class PenHandler extends Handler<PenTool> with ColoredHandler {
|
||||
DocumentInfo info, [
|
||||
Area? currentArea,
|
||||
]) => [...elements.values, ..._submittedElements]
|
||||
.map((e) {
|
||||
if (e.points.length > 1) {
|
||||
return PenRenderer(e.copyWith(id: createUniqueId()));
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.map(
|
||||
(e) => e.points.length > 1
|
||||
? PenRenderer(e.copyWith(id: createUniqueId()))
|
||||
: null,
|
||||
)
|
||||
.whereType<Renderer>()
|
||||
.toList();
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ class SyncService {
|
||||
}
|
||||
|
||||
RemoteSync? _createSync(String remote) {
|
||||
final storage = settingsCubit.state.getRemote(remote);
|
||||
final storage = settingsCubit.getRemote(remote);
|
||||
if (storage == null) {
|
||||
talker.warning('Remote storage not found: $remote');
|
||||
return null;
|
||||
|
||||
@@ -92,9 +92,7 @@ class _ProjectPageState extends State<ProjectPage> {
|
||||
final fileSystem = context.read<ButterflyFileSystem>();
|
||||
var location = widget.location;
|
||||
final absolute = widget.absolute;
|
||||
final remote = location != null
|
||||
? settingsCubit.state.getRemote(location.remote)
|
||||
: settingsCubit.state.getDefaultRemote();
|
||||
final remote = settingsCubit.getRemote(location?.remote);
|
||||
final documentSystem = fileSystem.buildDocumentSystem(remote);
|
||||
final embedding = widget.embedding;
|
||||
if (embedding != null) {
|
||||
|
||||
@@ -31,9 +31,11 @@ class _ConnectionButtonState extends State<ConnectionButton> {
|
||||
_updateConnection();
|
||||
}
|
||||
|
||||
void _updateConnection() => _currentConnection = (widget.currentRemote == null
|
||||
? null
|
||||
: context.read<SettingsCubit>().state.getRemote(widget.currentRemote));
|
||||
void _updateConnection() {
|
||||
final currentRemote = widget.currentRemote;
|
||||
final settingsCubit = context.read<SettingsCubit>();
|
||||
_currentConnection = settingsCubit.getRemote(currentRemote ?? '');
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant ConnectionButton oldWidget) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Add option to enable/disable thumbnails for notes ([#984](https://github.com/LinwoodDev/Butterfly/issues/984))
|
||||
* Add favorite templates to settings export
|
||||
* Add long press action for double/triple touch shortcuts
|
||||
* Fix opening local files when default storage is set to cloud
|
||||
* Fix stamp handler
|
||||
* Fix scaling on multiple elements
|
||||
* Fix preview element will shown after submitting
|
||||
|
||||
Reference in New Issue
Block a user