Skip to content

Commit 60f5de4

Browse files
authored
Remove redundant code, semaphores and todos (DevExpress#29079)
Co-authored-by: Vladimir Bushmanov <[email protected]>
1 parent 8c8cbd1 commit 60f5de4

File tree

25 files changed

+29
-122
lines changed

25 files changed

+29
-122
lines changed

packages/devextreme/js/__internal/scheduler/appointment_popup/m_form.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { extend } from '@js/core/utils/extend';
1414
import Form from '@js/ui/form';
1515
import { current, isFluent } from '@js/ui/themes';
1616
import { ExpressionUtils } from '@ts/scheduler/m_expression_utils';
17-
import { Semaphore } from '@ts/scheduler/r1/semaphore/index';
1817

1918
import { createAppointmentAdapter } from '../m_appointment_adapter';
2019
import timeZoneUtils from '../m_utils_time_zone';
@@ -63,15 +62,12 @@ export class AppointmentForm {
6362

6463
form: any;
6564

66-
// TODO: Why we need the "semaphore" in the sync code?
67-
// We should research it and delete it if redundant
68-
semaphore: Semaphore;
65+
// NOTE: flag to prevent double value set during form updating
66+
private isFormUpdating = false;
6967

7068
constructor(scheduler) {
7169
this.scheduler = scheduler;
7270
this.form = null;
73-
74-
this.semaphore = new Semaphore();
7571
}
7672

7773
get dxForm() {
@@ -194,7 +190,7 @@ export class AppointmentForm {
194190
const dateEditor = this.form.getEditor(dateExpr);
195191
const dateValue = dateSerialization.deserializeDate(dateEditor.option('value'));
196192

197-
if (this.semaphore.isFree() && dateValue && value && isNeedCorrect(dateValue, value)) {
193+
if (!this.isFormUpdating && dateValue && value && isNeedCorrect(dateValue, value)) {
198194
const duration = previousValue ? dateValue.getTime() - previousValue.getTime() : 0;
199195
dateEditor.option('value', new Date(value.getTime() + duration));
200196
}
@@ -337,7 +333,7 @@ export class AppointmentForm {
337333
const endDateEditor = this.form.getEditor(dataExprs.endDateExpr);
338334
const startDate = dateSerialization.deserializeDate(startDateEditor.option('value'));
339335

340-
if (this.semaphore.isFree() && startDate) {
336+
if (!this.isFormUpdating && startDate) {
341337
if (value) {
342338
const allDayStartDate = dateUtils.trimTime(startDate);
343339
startDateEditor.option('value', new Date(allDayStartDate));
@@ -459,8 +455,7 @@ export class AppointmentForm {
459455
}
460456

461457
updateFormData(formData) {
462-
this.semaphore.take();
463-
458+
this.isFormUpdating = true;
464459
this.form.option('formData', formData);
465460

466461
const dataAccessors = this.scheduler.getDataAccessors();
@@ -479,8 +474,7 @@ export class AppointmentForm {
479474
this.updateRecurrenceEditorStartDate(startDate, expr.recurrenceRuleExpr);
480475

481476
this.setEditorsType(allDay);
482-
483-
this.semaphore.release();
477+
this.isFormUpdating = false;
484478
}
485479

486480
private createDateBoxEditor(dataField, colSpan, firstDayOfWeek, label, cssClass, onValueChanged) {

packages/devextreme/js/__internal/scheduler/appointments/data_provider/m_appointment_filter.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,6 @@ export class AppointmentFilterBaseStrategy {
255255
}]];
256256
}
257257

258-
// TODO get rid of wrapper
259-
_createAppointmentFilter(filterOptions) {
260-
return this._createCombinedFilter(filterOptions);
261-
}
262-
263258
_filterAppointmentByResources(appointment, resources) {
264259
const checkAppointmentResourceValues = (resourceName, resourceIndex) => {
265260
const resourceGetter = this.dataAccessors.resources.getter[resourceName];
@@ -346,7 +341,7 @@ export class AppointmentFilterBaseStrategy {
346341
}
347342

348343
filterPreparedItems(filterOptions, preparedItems) {
349-
const combinedFilter = this._createAppointmentFilter(filterOptions);
344+
const combinedFilter = this._createCombinedFilter(filterOptions);
350345

351346
// @ts-expect-error
352347
return query(preparedItems)
@@ -451,7 +446,7 @@ export class AppointmentFilterVirtualStrategy extends AppointmentFilterBaseStrat
451446
filterOptions.forEach((option) => {
452447
combinedFilters.length && combinedFilters.push('or');
453448

454-
const filter = this._createAppointmentFilter(option);
449+
const filter = this._createCombinedFilter(option);
455450

456451
combinedFilters.push(filter);
457452
});

packages/devextreme/js/__internal/scheduler/appointments/m_appointment_collection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class SchedulerAppointments extends CollectionWidget {
7575
this._virtualAppointments = {};
7676
}
7777

78-
// TODO: remove when Collection moved to TS
7978
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8079
option(optionName?: string, value?: any) {
8180
return super.option(...arguments);

packages/devextreme/js/__internal/scheduler/appointments/m_view_model_generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class AppointmentViewModelGenerator {
3434
this.initRenderingStrategy(options);
3535

3636
const renderingStrategy = this.getRenderingStrategy();
37-
const positionMap = renderingStrategy.createTaskPositionMap(appointments); // TODO - appointments are mutated inside!
37+
const positionMap = renderingStrategy.createTaskPositionMap(appointments); // appointments are mutated inside!
3838
const shiftedViewModel = this.postProcess(appointments, positionMap);
3939
const viewModel = this.unshiftViewModelAppointmentsByViewOffset(shiftedViewModel, viewOffset);
4040

packages/devextreme/js/__internal/scheduler/appointments/rendering_strategies/m_strategy_agenda.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ class AgendaRenderingStrategy extends BaseRenderingStrategy {
193193
replaceWrongEndDate(adapter, startDate, endDate, this.cellDuration, this.dataAccessors);
194194
}
195195

196-
// TODO: get rid of an extra 'needClearSettings' argument
197-
calculateRows(appointments, agendaDuration, currentDate, needClearSettings?) {
196+
calculateRows(appointments, agendaDuration, currentDate) {
198197
this._rows = [];
199198
currentDate = dateUtils.trimTime(new Date(currentDate));
200199

@@ -218,8 +217,6 @@ class AgendaRenderingStrategy extends BaseRenderingStrategy {
218217

219218
this.replaceWrongAppointmentEndDate(appointment, startDate, endDate);
220219

221-
needClearSettings && delete appointment.settings;
222-
223220
const result = this.instance.getAppointmentsInstance()._processRecurrenceAppointment(appointment, index, false);
224221
appts.parts = appts.parts.concat(result.parts);
225222
appts.indexes = appts.indexes.concat(result.indexes);

packages/devextreme/js/__internal/scheduler/m_appointment_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class AppointmentAdapter {
169169

170170
source(serializeDate = false) {
171171
if (serializeDate) {
172-
// TODO: hack for use dateSerializationFormat
172+
// hack for use dateSerializationFormat
173173
const clonedAdapter = this.clone();
174174
clonedAdapter.startDate = this.startDate;
175175
clonedAdapter.endDate = this.endDate;

packages/devextreme/js/__internal/scheduler/m_loading.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export function show(options) {
2929
}
3030

3131
export function hide() {
32-
// todo: hot fix for case without viewport
33-
32+
// hot fix for case without viewport
3433
if (!loading) {
3534
// @ts-expect-error
3635
return new Deferred().resolve();

packages/devextreme/js/__internal/scheduler/m_recurrence_editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const MONTH_OF_YEAR = 'dx-recurrence-selectbox-month-of-year';
3636

3737
const recurrentEditorNumberBoxWidth = 70;
3838
const recurrentEditorSelectBoxWidth = 120;
39-
const defaultRecurrenceTypeIndex = 1; // TODO default daily recurrence
39+
const defaultRecurrenceTypeIndex = 1; // default daily recurrence
4040

4141
const frequenciesMessages = [
4242
/* {

packages/devextreme/js/__internal/scheduler/m_scheduler.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ class Scheduler extends Widget<any> {
15251525
this._validateKeyFieldIfAgendaExist();
15261526
}
15271527

1528-
_isDataSourceLoaded() { // TODO
1528+
_isDataSourceLoaded() {
15291529
return this._dataSource && this._dataSource.isLoaded();
15301530
}
15311531

@@ -1637,17 +1637,13 @@ class Scheduler extends Widget<any> {
16371637
return this._getCurrentViewOption('cellDuration');
16381638
}
16391639

1640-
_getCurrentViewType() { // TODO get rid of mapping
1641-
return this.currentViewType;
1642-
}
1643-
16441640
_renderWorkSpace(groups) {
16451641
this._readyToRenderAppointments && this._toggleSmallClass();
16461642
const $workSpace = $('<div>').appendTo(this._mainContainer);
16471643

16481644
const countConfig = this._getViewCountConfig();
16491645

1650-
const workSpaceComponent = VIEWS_CONFIG[this._getCurrentViewType()].workSpace;
1646+
const workSpaceComponent = VIEWS_CONFIG[this.currentViewType].workSpace;
16511647
const workSpaceConfig = this._workSpaceConfig(groups, countConfig);
16521648
// @ts-expect-error
16531649
this._workSpace = this._createComponent($workSpace, workSpaceComponent, workSpaceConfig);
@@ -2236,7 +2232,7 @@ class Scheduler extends Widget<any> {
22362232
}
22372233

22382234
/// #DEBUG
2239-
getAppointmentDetailsForm() { // TODO for tests
2235+
getAppointmentDetailsForm() { // for tests
22402236
return this._appointmentForm.form;
22412237
}
22422238
/// #ENDDEBUG
@@ -2647,7 +2643,6 @@ class Scheduler extends Widget<any> {
26472643
private validateOptions(): void {
26482644
const currentViewOptions = {
26492645
...this.option(),
2650-
// TODO: Check it before 24.1 release
26512646
// NOTE: We override this.option values here
26522647
// because the old validation logic checked only current view options.
26532648
// Changing it and validate all views configuration will be a BC.

packages/devextreme/js/__internal/scheduler/m_subscribes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const subscribes = {
126126
this.timeZoneCalculator,
127127
);
128128

129-
// TODO pull out time zone converting from appointment adapter for knockout(T947938)
129+
// pull out time zone converting from appointment adapter for knockout(T947938)
130130
const startDate = this.timeZoneCalculator.createDate(targetedAdapter.startDate, { path: 'toGrid' });
131131
const endDate = this.timeZoneCalculator.createDate(targetedAdapter.endDate, { path: 'toGrid' });
132132

0 commit comments

Comments
 (0)