orgs impl
This commit is contained in:
@@ -26,13 +26,18 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
|
||||
Emitter<OrganizationState> emit,
|
||||
) async {
|
||||
emit(OrganizationLoading());
|
||||
// Simulate loading orgs from API
|
||||
final orgs = [
|
||||
const Organization(id: 'org1', name: 'Personal', role: 'admin'),
|
||||
const Organization(id: 'org2', name: 'Company Inc', role: 'edit'),
|
||||
const Organization(id: 'org3', name: 'Side Project', role: 'admin'),
|
||||
];
|
||||
emit(OrganizationLoaded(organizations: orgs, selectedOrg: orgs.first));
|
||||
try {
|
||||
// Simulate loading orgs from API
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final orgs = [
|
||||
const Organization(id: 'org1', name: 'Personal', role: 'admin'),
|
||||
const Organization(id: 'org2', name: 'Company Inc', role: 'edit'),
|
||||
const Organization(id: 'org3', name: 'Side Project', role: 'admin'),
|
||||
];
|
||||
emit(OrganizationLoaded(organizations: orgs, selectedOrg: orgs.first));
|
||||
} catch (e) {
|
||||
emit(OrganizationError(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectOrganization(
|
||||
@@ -49,6 +54,7 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
|
||||
OrganizationLoaded(
|
||||
organizations: currentState.organizations,
|
||||
selectedOrg: selected,
|
||||
isLoading: false,
|
||||
),
|
||||
);
|
||||
// Reset all dependent blocs
|
||||
@@ -63,21 +69,66 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
|
||||
void _onCreateOrganization(
|
||||
CreateOrganization event,
|
||||
Emitter<OrganizationState> emit,
|
||||
) {
|
||||
) async {
|
||||
final currentState = state;
|
||||
if (currentState is OrganizationLoaded) {
|
||||
final newOrg = Organization(
|
||||
id: 'org${currentState.organizations.length + 1}',
|
||||
name: event.name,
|
||||
role: 'admin',
|
||||
final name = event.name.trim();
|
||||
if (name.isEmpty) {
|
||||
emit(
|
||||
OrganizationLoaded(
|
||||
organizations: currentState.organizations,
|
||||
selectedOrg: currentState.selectedOrg,
|
||||
isLoading: false,
|
||||
error: 'Organization name cannot be empty',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (currentState.organizations.any((org) => org.name == name)) {
|
||||
emit(
|
||||
OrganizationLoaded(
|
||||
organizations: currentState.organizations,
|
||||
selectedOrg: currentState.selectedOrg,
|
||||
isLoading: false,
|
||||
error: 'Organization with this name already exists',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
emit(
|
||||
OrganizationLoaded(
|
||||
organizations: currentState.organizations,
|
||||
selectedOrg: currentState.selectedOrg,
|
||||
isLoading: true,
|
||||
),
|
||||
);
|
||||
final updatedOrgs = [...currentState.organizations, newOrg];
|
||||
emit(OrganizationLoaded(organizations: updatedOrgs, selectedOrg: newOrg));
|
||||
// Reset blocs and load permissions for new org
|
||||
permissionBloc.add(PermissionsReset());
|
||||
fileBrowserBloc.add(ResetFileBrowser());
|
||||
uploadBloc.add(ResetUploads());
|
||||
permissionBloc.add(LoadPermissions(newOrg.id));
|
||||
try {
|
||||
// Simulate API call
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final newOrg = Organization(
|
||||
id: 'org${currentState.organizations.length + 1}',
|
||||
name: name,
|
||||
role: 'admin',
|
||||
);
|
||||
final updatedOrgs = [...currentState.organizations, newOrg];
|
||||
emit(
|
||||
OrganizationLoaded(organizations: updatedOrgs, selectedOrg: newOrg),
|
||||
);
|
||||
// Reset blocs and load permissions for new org
|
||||
permissionBloc.add(PermissionsReset());
|
||||
fileBrowserBloc.add(ResetFileBrowser());
|
||||
uploadBloc.add(ResetUploads());
|
||||
permissionBloc.add(LoadPermissions(newOrg.id));
|
||||
} catch (e) {
|
||||
emit(
|
||||
OrganizationLoaded(
|
||||
organizations: currentState.organizations,
|
||||
selectedOrg: currentState.selectedOrg,
|
||||
isLoading: false,
|
||||
error: e.toString(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,23 @@ class OrganizationLoading extends OrganizationState {}
|
||||
class OrganizationLoaded extends OrganizationState {
|
||||
final List<Organization> organizations;
|
||||
final Organization? selectedOrg;
|
||||
final bool isLoading;
|
||||
final String? error;
|
||||
|
||||
const OrganizationLoaded({required this.organizations, this.selectedOrg});
|
||||
const OrganizationLoaded({
|
||||
required this.organizations,
|
||||
this.selectedOrg,
|
||||
this.isLoading = false,
|
||||
this.error,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props => [organizations, selectedOrg ?? ''];
|
||||
List<Object> get props => [
|
||||
organizations,
|
||||
selectedOrg ?? '',
|
||||
isLoading,
|
||||
error ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
class OrganizationError extends OrganizationState {
|
||||
|
||||
@@ -6,9 +6,8 @@ import '../blocs/auth/auth_bloc.dart';
|
||||
import '../blocs/auth/auth_state.dart';
|
||||
import '../blocs/organization/organization_bloc.dart';
|
||||
import '../blocs/organization/organization_event.dart';
|
||||
import '../blocs/permission/permission_bloc.dart';
|
||||
import '../blocs/file_browser/file_browser_bloc.dart';
|
||||
import '../blocs/upload/upload_bloc.dart';
|
||||
import '../blocs/file_browser/file_browser_event.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../theme/modern_glass_button.dart';
|
||||
import 'login_form.dart';
|
||||
@@ -172,92 +171,9 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
}
|
||||
|
||||
Widget _buildDrive(OrganizationState state) {
|
||||
if (state is OrganizationLoaded && state.selectedOrg != null) {
|
||||
return FileExplorer(orgId: state.selectedOrg!.id);
|
||||
} else {
|
||||
return const FileExplorer(orgId: 'org1');
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildPersonalContent(OrganizationState state) {
|
||||
if (state is OrganizationLoaded && state.selectedOrg != null) {
|
||||
return FileExplorer(orgId: state.selectedOrg!.id);
|
||||
} else {
|
||||
return const FileExplorer(orgId: 'org1');
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildOrganizationsContent(OrganizationState state) {
|
||||
if (state is OrganizationLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is OrganizationError) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('Error: ${state.error}'),
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<OrganizationBloc>().add(LoadOrganizations()),
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (state is OrganizationLoaded) {
|
||||
final orgs = state.organizations;
|
||||
if (orgs.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('No organizations yet. Create one to get started.'),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => _showCreateOrgDialog(context),
|
||||
child: const Text('+ Add organization'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: orgs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final org = orgs[index];
|
||||
final isCurrent = state.selectedOrg?.id == org.id;
|
||||
return ListTile(
|
||||
title: Text(org.name),
|
||||
subtitle: isCurrent ? const Text('(current)') : null,
|
||||
trailing: isCurrent
|
||||
? null
|
||||
: TextButton(
|
||||
onPressed: () {
|
||||
context.read<OrganizationBloc>().add(
|
||||
SelectOrganization(org.id),
|
||||
);
|
||||
},
|
||||
child: const Text('Switch'),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: ElevatedButton(
|
||||
onPressed: () => _showCreateOrgDialog(context),
|
||||
child: const Text('+ Add organization'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Center(child: Text('Loading organizations...'));
|
||||
}
|
||||
return state is OrganizationLoaded && state.selectedOrg != null
|
||||
? FileExplorer(orgId: state.selectedOrg!.id)
|
||||
: const FileExplorer(orgId: 'org1');
|
||||
}
|
||||
|
||||
Widget _buildNavButton(String label, IconData icon, {bool isAvatar = false}) {
|
||||
@@ -333,30 +249,53 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
Container(
|
||||
decoration: AppTheme.glassDecoration,
|
||||
child: isLoggedIn
|
||||
? BlocBuilder<
|
||||
? BlocListener<
|
||||
OrganizationBloc,
|
||||
OrganizationState
|
||||
>(
|
||||
builder: (context, orgState) {
|
||||
if (orgState is OrganizationInitial) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
context
|
||||
.read<OrganizationBloc>()
|
||||
.add(LoadOrganizations());
|
||||
});
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
_buildOrgRow(context),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: _buildDrive(orgState),
|
||||
listener: (context, state) {
|
||||
if (state is OrganizationLoaded &&
|
||||
state.selectedOrg != null) {
|
||||
// Reload file browser when org changes
|
||||
context.read<FileBrowserBloc>().add(
|
||||
LoadDirectory(
|
||||
orgId: state.selectedOrg!.id,
|
||||
path: '/',
|
||||
),
|
||||
],
|
||||
);
|
||||
);
|
||||
}
|
||||
},
|
||||
child:
|
||||
BlocBuilder<
|
||||
OrganizationBloc,
|
||||
OrganizationState
|
||||
>(
|
||||
builder: (context, orgState) {
|
||||
if (orgState
|
||||
is OrganizationInitial) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
context
|
||||
.read<
|
||||
OrganizationBloc
|
||||
>()
|
||||
.add(
|
||||
LoadOrganizations(),
|
||||
);
|
||||
});
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
_buildOrgRow(context),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: _buildDrive(orgState),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: const LoginForm(),
|
||||
),
|
||||
|
||||
@@ -8,179 +8,95 @@ import '../repositories/file_repository.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
class MockFileRepository implements FileRepository {
|
||||
final List<FileItem> _files = [
|
||||
FileItem(
|
||||
name: 'Documents',
|
||||
path: '/Documents',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Images',
|
||||
path: '/Images',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'report.pdf',
|
||||
path: '/report.pdf',
|
||||
type: FileType.file,
|
||||
size: 1024,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'code.dart',
|
||||
path: '/code.dart',
|
||||
type: FileType.file,
|
||||
size: 512,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
// Add more files for pagination testing
|
||||
FileItem(
|
||||
name: 'presentation.pptx',
|
||||
path: '/presentation.pptx',
|
||||
type: FileType.file,
|
||||
size: 2048,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'data.xlsx',
|
||||
path: '/data.xlsx',
|
||||
type: FileType.file,
|
||||
size: 1024,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'video.mp4',
|
||||
path: '/video.mp4',
|
||||
type: FileType.file,
|
||||
size: 102400,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'archive.zip',
|
||||
path: '/archive.zip',
|
||||
type: FileType.file,
|
||||
size: 5120,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'notes.txt',
|
||||
path: '/notes.txt',
|
||||
type: FileType.file,
|
||||
size: 256,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'config.json',
|
||||
path: '/config.json',
|
||||
type: FileType.file,
|
||||
size: 128,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'script.js',
|
||||
path: '/script.js',
|
||||
type: FileType.file,
|
||||
size: 256,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'styles.css',
|
||||
path: '/styles.css',
|
||||
type: FileType.file,
|
||||
size: 512,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'index.html',
|
||||
path: '/index.html',
|
||||
type: FileType.file,
|
||||
size: 1024,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'database.db',
|
||||
path: '/database.db',
|
||||
type: FileType.file,
|
||||
size: 20480,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'logs',
|
||||
path: '/logs',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'temp',
|
||||
path: '/temp',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'backup',
|
||||
path: '/backup',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Music',
|
||||
path: '/Music',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Videos',
|
||||
path: '/Videos',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Projects',
|
||||
path: '/Projects',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Downloads',
|
||||
path: '/Downloads',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Pictures',
|
||||
path: '/Pictures',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Documents2',
|
||||
path: '/Documents2',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Archive',
|
||||
path: '/Archive',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'OldFiles',
|
||||
path: '/OldFiles',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
];
|
||||
final Map<String, List<FileItem>> _orgFiles = {};
|
||||
|
||||
List<FileItem> _getFilesForOrg(String orgId) {
|
||||
if (!_orgFiles.containsKey(orgId)) {
|
||||
// Initialize with different files per org
|
||||
if (orgId == 'org1') {
|
||||
_orgFiles[orgId] = [
|
||||
FileItem(
|
||||
name: 'Personal Documents',
|
||||
path: '/Personal Documents',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'Photos',
|
||||
path: '/Photos',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'resume.pdf',
|
||||
path: '/resume.pdf',
|
||||
type: FileType.file,
|
||||
size: 1024,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'notes.txt',
|
||||
path: '/notes.txt',
|
||||
type: FileType.file,
|
||||
size: 256,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
];
|
||||
} else if (orgId == 'org2') {
|
||||
_orgFiles[orgId] = [
|
||||
FileItem(
|
||||
name: 'Company Reports',
|
||||
path: '/Company Reports',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'annual_report.pdf',
|
||||
path: '/annual_report.pdf',
|
||||
type: FileType.file,
|
||||
size: 2048,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'presentation.pptx',
|
||||
path: '/presentation.pptx',
|
||||
type: FileType.file,
|
||||
size: 4096,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
];
|
||||
} else if (orgId == 'org3') {
|
||||
_orgFiles[orgId] = [
|
||||
FileItem(
|
||||
name: 'Project Code',
|
||||
path: '/Project Code',
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
FileItem(
|
||||
name: 'side_project.dart',
|
||||
path: '/side_project.dart',
|
||||
type: FileType.file,
|
||||
size: 512,
|
||||
lastModified: DateTime.now(),
|
||||
),
|
||||
];
|
||||
} else {
|
||||
// Default for new orgs
|
||||
_orgFiles[orgId] = [];
|
||||
}
|
||||
}
|
||||
return _orgFiles[orgId]!;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<FileItem>> getFiles(String orgId, String path) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final files = _getFilesForOrg(orgId);
|
||||
if (path == '/') {
|
||||
return _files.where((f) => !f.path.substring(1).contains('/')).toList();
|
||||
return files.where((f) => !f.path.substring(1).contains('/')).toList();
|
||||
} else {
|
||||
return _files
|
||||
return files
|
||||
.where((f) => f.path.startsWith('$path/') && f.path != path)
|
||||
.toList();
|
||||
}
|
||||
@@ -188,10 +104,9 @@ class MockFileRepository implements FileRepository {
|
||||
|
||||
@override
|
||||
Future<FileItem?> getFile(String orgId, String path) async {
|
||||
return _files.firstWhere(
|
||||
(f) => f.path == path,
|
||||
orElse: () => null as FileItem,
|
||||
);
|
||||
final files = _getFilesForOrg(orgId);
|
||||
final index = files.indexWhere((f) => f.path == path);
|
||||
return index != -1 ? files[index] : null;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -218,7 +133,8 @@ class MockFileRepository implements FileRepository {
|
||||
|
||||
@override
|
||||
Future<void> deleteFile(String orgId, String path) async {
|
||||
_files.removeWhere((f) => f.path == path);
|
||||
final files = _getFilesForOrg(orgId);
|
||||
files.removeWhere((f) => f.path == path);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -234,7 +150,8 @@ class MockFileRepository implements FileRepository {
|
||||
final newPath = parentPath == '/'
|
||||
? '/$normalizedName'
|
||||
: '$parentPath/$normalizedName';
|
||||
_files.add(
|
||||
final files = _getFilesForOrg(orgId);
|
||||
files.add(
|
||||
FileItem(
|
||||
name: normalizedName,
|
||||
path: newPath,
|
||||
@@ -251,12 +168,13 @@ class MockFileRepository implements FileRepository {
|
||||
String targetPath,
|
||||
) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final fileIndex = _files.indexWhere((f) => f.path == sourcePath);
|
||||
final files = _getFilesForOrg(orgId);
|
||||
final fileIndex = files.indexWhere((f) => f.path == sourcePath);
|
||||
if (fileIndex != -1) {
|
||||
final file = _files[fileIndex];
|
||||
final file = files[fileIndex];
|
||||
final newName = file.path.split('/').last;
|
||||
final newPath = targetPath == '/' ? '/$newName' : '$targetPath/$newName';
|
||||
_files[fileIndex] = FileItem(
|
||||
files[fileIndex] = FileItem(
|
||||
name: file.name,
|
||||
path: newPath,
|
||||
type: file.type,
|
||||
@@ -269,12 +187,13 @@ class MockFileRepository implements FileRepository {
|
||||
@override
|
||||
Future<void> renameFile(String orgId, String path, String newName) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final fileIndex = _files.indexWhere((f) => f.path == path);
|
||||
final files = _getFilesForOrg(orgId);
|
||||
final fileIndex = files.indexWhere((f) => f.path == path);
|
||||
if (fileIndex != -1) {
|
||||
final file = _files[fileIndex];
|
||||
final file = files[fileIndex];
|
||||
final parentPath = p.dirname(path);
|
||||
final newPath = parentPath == '.' ? '/$newName' : '$parentPath/$newName';
|
||||
_files[fileIndex] = FileItem(
|
||||
files[fileIndex] = FileItem(
|
||||
name: newName,
|
||||
path: newPath,
|
||||
type: file.type,
|
||||
@@ -287,7 +206,8 @@ class MockFileRepository implements FileRepository {
|
||||
@override
|
||||
Future<List<FileItem>> searchFiles(String orgId, String query) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
return _files
|
||||
final files = _getFilesForOrg(orgId);
|
||||
return files
|
||||
.where((f) => f.name.toLowerCase().contains(query.toLowerCase()))
|
||||
.toList();
|
||||
}
|
||||
@@ -295,7 +215,8 @@ class MockFileRepository implements FileRepository {
|
||||
@override
|
||||
Future<void> uploadFile(String orgId, FileItem file) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
_files.add(file);
|
||||
final files = _getFilesForOrg(orgId);
|
||||
files.add(file);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user