mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: unable to get latest workspaces on desktop
This commit is contained in:
parent
4eb4ff1a32
commit
b6fd7ca4f9
@ -55,6 +55,16 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
|
|||||||
fetchWorkspaces: () async {
|
fetchWorkspaces: () async {
|
||||||
final result = await _fetchWorkspaces();
|
final result = await _fetchWorkspaces();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
final currentWorkspace = result.$1;
|
||||||
|
final workspaces = result.$2;
|
||||||
|
// the equal function has been overridden.
|
||||||
|
if (_deepCollectionEquality.equals(
|
||||||
|
workspaces,
|
||||||
|
state.workspaces,
|
||||||
|
) &&
|
||||||
|
currentWorkspace == state.currentWorkspace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
currentWorkspace: result.$1,
|
currentWorkspace: result.$1,
|
||||||
@ -255,8 +265,10 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
updateWorkspaces: (workspaces) async {
|
updateWorkspaces: (workspaces) async {
|
||||||
if (!const DeepCollectionEquality()
|
if (!_deepCollectionEquality.equals(
|
||||||
.equals(workspaces.items, state.workspaces)) {
|
workspaces.items,
|
||||||
|
state.workspaces,
|
||||||
|
)) {
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
workspaces: workspaces.items,
|
workspaces: workspaces.items,
|
||||||
@ -278,6 +290,8 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
|
|||||||
final UserProfilePB userProfile;
|
final UserProfilePB userProfile;
|
||||||
final UserBackendService _userService;
|
final UserBackendService _userService;
|
||||||
final UserListener _listener;
|
final UserListener _listener;
|
||||||
|
final DeepCollectionEquality _deepCollectionEquality =
|
||||||
|
const DeepCollectionEquality();
|
||||||
|
|
||||||
Future<
|
Future<
|
||||||
(
|
(
|
||||||
|
@ -148,6 +148,11 @@ class _SidebarSwitchWorkspaceButtonState
|
|||||||
direction: PopoverDirection.bottomWithCenterAligned,
|
direction: PopoverDirection.bottomWithCenterAligned,
|
||||||
offset: const Offset(0, 10),
|
offset: const Offset(0, 10),
|
||||||
constraints: const BoxConstraints(maxWidth: 260, maxHeight: 600),
|
constraints: const BoxConstraints(maxWidth: 260, maxHeight: 600),
|
||||||
|
onOpen: () {
|
||||||
|
context.read<UserWorkspaceBloc>().add(
|
||||||
|
const UserWorkspaceEvent.fetchWorkspaces(),
|
||||||
|
);
|
||||||
|
},
|
||||||
popupBuilder: (_) {
|
popupBuilder: (_) {
|
||||||
return BlocProvider<UserWorkspaceBloc>.value(
|
return BlocProvider<UserWorkspaceBloc>.value(
|
||||||
value: context.read<UserWorkspaceBloc>(),
|
value: context.read<UserWorkspaceBloc>(),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
import 'package:appflowy_popover/src/layout.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:appflowy_popover/src/layout.dart';
|
|
||||||
|
|
||||||
import 'mask.dart';
|
import 'mask.dart';
|
||||||
import 'mutex.dart';
|
import 'mutex.dart';
|
||||||
|
|
||||||
@ -79,7 +78,8 @@ class Popover extends StatefulWidget {
|
|||||||
/// The direction of the popover
|
/// The direction of the popover
|
||||||
final PopoverDirection direction;
|
final PopoverDirection direction;
|
||||||
|
|
||||||
final void Function()? onClose;
|
final VoidCallback? onOpen;
|
||||||
|
final VoidCallback? onClose;
|
||||||
final Future<bool> Function()? canClose;
|
final Future<bool> Function()? canClose;
|
||||||
|
|
||||||
final bool asBarrier;
|
final bool asBarrier;
|
||||||
@ -109,6 +109,7 @@ class Popover extends StatefulWidget {
|
|||||||
this.direction = PopoverDirection.rightWithTopAligned,
|
this.direction = PopoverDirection.rightWithTopAligned,
|
||||||
this.mutex,
|
this.mutex,
|
||||||
this.windowPadding,
|
this.windowPadding,
|
||||||
|
this.onOpen,
|
||||||
this.onClose,
|
this.onClose,
|
||||||
this.canClose,
|
this.canClose,
|
||||||
this.asBarrier = false,
|
this.asBarrier = false,
|
||||||
@ -228,6 +229,7 @@ class PopoverState extends State<Popover> {
|
|||||||
child: _buildClickHandler(
|
child: _buildClickHandler(
|
||||||
widget.child,
|
widget.child,
|
||||||
() {
|
() {
|
||||||
|
widget.onOpen?.call();
|
||||||
if (widget.triggerActions & PopoverTriggerFlags.click != 0) {
|
if (widget.triggerActions & PopoverTriggerFlags.click != 0) {
|
||||||
showOverlay();
|
showOverlay();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/decoration.dart';
|
import 'package:flowy_infra_ui/style_widget/decoration.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AppFlowyPopover extends StatelessWidget {
|
class AppFlowyPopover extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -10,7 +9,8 @@ class AppFlowyPopover extends StatelessWidget {
|
|||||||
final PopoverDirection direction;
|
final PopoverDirection direction;
|
||||||
final int triggerActions;
|
final int triggerActions;
|
||||||
final BoxConstraints constraints;
|
final BoxConstraints constraints;
|
||||||
final void Function()? onClose;
|
final VoidCallback? onOpen;
|
||||||
|
final VoidCallback? onClose;
|
||||||
final Future<bool> Function()? canClose;
|
final Future<bool> Function()? canClose;
|
||||||
final PopoverMutex? mutex;
|
final PopoverMutex? mutex;
|
||||||
final Offset? offset;
|
final Offset? offset;
|
||||||
@ -35,6 +35,7 @@ class AppFlowyPopover extends StatelessWidget {
|
|||||||
required this.child,
|
required this.child,
|
||||||
required this.popupBuilder,
|
required this.popupBuilder,
|
||||||
this.direction = PopoverDirection.rightWithTopAligned,
|
this.direction = PopoverDirection.rightWithTopAligned,
|
||||||
|
this.onOpen,
|
||||||
this.onClose,
|
this.onClose,
|
||||||
this.canClose,
|
this.canClose,
|
||||||
this.constraints = const BoxConstraints(maxWidth: 240, maxHeight: 600),
|
this.constraints = const BoxConstraints(maxWidth: 240, maxHeight: 600),
|
||||||
@ -54,6 +55,7 @@ class AppFlowyPopover extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Popover(
|
return Popover(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
onOpen: onOpen,
|
||||||
onClose: onClose,
|
onClose: onClose,
|
||||||
canClose: canClose,
|
canClose: canClose,
|
||||||
direction: direction,
|
direction: direction,
|
||||||
|
Loading…
Reference in New Issue
Block a user