snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
68
react/features/file-sharing/reducer.ts
Normal file
68
react/features/file-sharing/reducer.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import {
|
||||
ADD_FILE,
|
||||
UPDATE_FILE_UPLOAD_PROGRESS,
|
||||
_FILE_LIST_RECEIVED,
|
||||
_FILE_REMOVED
|
||||
} from './actionTypes';
|
||||
import { IFileMetadata } from './types';
|
||||
|
||||
export interface IFileSharingState {
|
||||
files: Map<string, IFileMetadata>;
|
||||
}
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
files: new Map<string, IFileMetadata>()
|
||||
};
|
||||
|
||||
ReducerRegistry.register<IFileSharingState>('features/file-sharing',
|
||||
(state = DEFAULT_STATE, action): IFileSharingState => {
|
||||
switch (action.type) {
|
||||
case ADD_FILE: {
|
||||
const newFiles = new Map(state.files);
|
||||
|
||||
newFiles.set(action.file.fileId, action.file);
|
||||
|
||||
return {
|
||||
...state,
|
||||
files: newFiles
|
||||
};
|
||||
}
|
||||
|
||||
case _FILE_REMOVED: {
|
||||
const newFiles = new Map(state.files);
|
||||
|
||||
newFiles.delete(action.fileId);
|
||||
|
||||
return {
|
||||
...state,
|
||||
files: newFiles
|
||||
};
|
||||
}
|
||||
|
||||
case UPDATE_FILE_UPLOAD_PROGRESS: {
|
||||
const newFiles = new Map(state.files);
|
||||
const file = newFiles.get(action.fileId);
|
||||
|
||||
if (file) {
|
||||
newFiles.set(action.fileId, { ...file, progress: action.progress });
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
files: newFiles
|
||||
};
|
||||
}
|
||||
|
||||
case _FILE_LIST_RECEIVED: {
|
||||
return {
|
||||
...state,
|
||||
files: new Map(Object.entries(action.files))
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user