@@ -6,6 +6,7 @@ import 'package:appflowy/startup/startup.dart';
66import 'package:appflowy/user/application/reminder/reminder_bloc.dart' ;
77import 'package:appflowy/user/application/user_listener.dart' ;
88import 'package:appflowy/user/application/user_service.dart' ;
9+ import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart' ;
910import 'package:appflowy_backend/log.dart' ;
1011import 'package:appflowy_backend/protobuf/flowy-error/code.pbenum.dart' ;
1112import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart' ;
@@ -119,28 +120,36 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
119120 Emitter <UserWorkspaceState > emit,
120121 String workspaceId,
121122 ) async {
122- unawaited ( UserBackendService . getWorkspaceSubscriptionInfo (workspaceId). fold (
123- (workspaceSubscriptionInfo) {
124- if (! isClosed ) {
125- return ;
126- }
123+ final enabled = await isBillingEnabled ();
124+ // If billing is not enabled, we don't need to fetch the workspace subscription info
125+ if (! enabled ) {
126+ return ;
127+ }
127128
128- if (state.currentWorkspace? .workspaceId != workspaceId) {
129- return ;
130- }
129+ unawaited (
130+ UserBackendService .getWorkspaceSubscriptionInfo (workspaceId).fold (
131+ (workspaceSubscriptionInfo) {
132+ if (isClosed) {
133+ return ;
134+ }
131135
132- Log . debug (
133- 'fetch workspace subscription info: $ workspaceId , $ workspaceSubscriptionInfo ' ,
134- );
136+ if (state.currentWorkspace ? .workspaceId != workspaceId) {
137+ return ;
138+ }
135139
136- emit (
137- state.copyWith (
138- workspaceSubscriptionInfo: workspaceSubscriptionInfo,
139- ),
140- );
141- },
142- (e) => Log .error ('fetch workspace subscription info error: $e ' ),
143- ));
140+ Log .debug (
141+ 'fetch workspace subscription info: $workspaceId , $workspaceSubscriptionInfo ' ,
142+ );
143+
144+ emit (
145+ state.copyWith (
146+ workspaceSubscriptionInfo: workspaceSubscriptionInfo,
147+ ),
148+ );
149+ },
150+ (e) => Log .error ('fetch workspace subscription info error: $e ' ),
151+ ),
152+ );
144153 }
145154
146155 Future <void > _initializeWorkspaces (Emitter <UserWorkspaceState > emit) async {
0 commit comments