From 088dea628b7a364ac663ab9a397da444ff45fdc9 Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:06:23 +0200 Subject: [PATCH 1/8] feat: add isDeleted field to IntervalTO interface ever-co/ever-gauzy-desktop#44 --- packages/desktop-libs/src/lib/offline/dto/interval.dto.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/desktop-libs/src/lib/offline/dto/interval.dto.ts b/packages/desktop-libs/src/lib/offline/dto/interval.dto.ts index c3e05698940..c49e256132d 100644 --- a/packages/desktop-libs/src/lib/offline/dto/interval.dto.ts +++ b/packages/desktop-libs/src/lib/offline/dto/interval.dto.ts @@ -14,6 +14,7 @@ export interface IntervalTO extends BaseTO { stoppedAt: Date; synced: boolean; timerId: number; + isDeleted: boolean; } export const TABLE_NAME_INTERVALS = 'intervals'; From 6e61ddb61a24f84b7d0eeba111b28c8b86508508 Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:07:18 +0200 Subject: [PATCH 2/8] refactor: DAO methods to soft delete intervals instead of hard delete Updated DAO methods to use soft deletion by setting 'isDeleted' flag instead of hard delete for intervals, improving data integrity and allowing for potential data recovery. Also added additional conditions to filter out deleted intervals. ever-co/ever-gauzy-desktop#44 --- .../src/lib/offline/dao/interval.dao.ts | 92 +++++++------------ 1 file changed, 35 insertions(+), 57 deletions(-) diff --git a/packages/desktop-libs/src/lib/offline/dao/interval.dao.ts b/packages/desktop-libs/src/lib/offline/dao/interval.dao.ts index e03a5d7c93e..58dd9d6e853 100644 --- a/packages/desktop-libs/src/lib/offline/dao/interval.dao.ts +++ b/packages/desktop-libs/src/lib/offline/dao/interval.dao.ts @@ -13,25 +13,30 @@ export class IntervalDAO implements DAO { this._trx = new IntervalTransaction(this._provider); } + private _isJSON(value: any): boolean { + try { + JSON.parse(value); + return true; + } catch (error) { + return false; + } + } + public async findAll(): Promise { try { - return await this._provider.connection( - TABLE_NAME_INTERVALS - ); + return await this._provider.connection(TABLE_NAME_INTERVALS); } catch (error) { console.log('[dao]: ', 'interval backed up fails : ', error); return []; } } - public async findAllSynced( - isSynced: boolean, - user: UserTO - ): Promise { + public async findAllSynced(isSynced: boolean, user: UserTO): Promise { try { return await this._provider .connection(TABLE_NAME_INTERVALS) .where('employeeId', user.employeeId) + .andWhere('isDeleted', false) .andWhere('synced', isSynced); } catch (error) { console.log('[dao]: ', 'interval backed up fails : ', error); @@ -46,7 +51,8 @@ export class IntervalDAO implements DAO { try { return await this._provider .connection(TABLE_NAME_INTERVALS) - .where('id', id)[0]; + .where('id', id) + .andWhere('isDeleted', false)[0]; } catch (error) { console.log('[dao]: ', 'fail on find interval : ', error); } @@ -62,20 +68,13 @@ export class IntervalDAO implements DAO { public async delete(value: Partial): Promise { try { - return await this._provider - .connection(TABLE_NAME_INTERVALS) - .where('id', value.id) - .del(); + return await this._provider.connection(TABLE_NAME_INTERVALS).where('id', value.id).del(); } catch (error) { console.log('[dao]: ', 'interval deleted fails : ', error); } } - public async backedUpNoSynced( - startedAt: Date, - stoppedAt: Date, - user: UserTO - ): Promise { + public async backedUpNoSynced(startedAt: Date, stoppedAt: Date, user: UserTO): Promise { try { return await this._provider .connection(TABLE_NAME_INTERVALS) @@ -85,6 +84,7 @@ export class IntervalDAO implements DAO { qb .whereBetween('startedAt', [new Date(startedAt), new Date(stoppedAt)]) .andWhere('synced', false) + .andWhere('isDeleted', false) ); } catch (error) { console.log('[dao]: ', 'interval backup fails : ', error); @@ -105,6 +105,7 @@ export class IntervalDAO implements DAO { .connection(TABLE_NAME_INTERVALS) .count('* as total') .where('employeeId', user.employeeId) + .where('isDeleted', false) .andWhere('synced', isSynced); } catch (error) { console.log('[dao]: ', 'interval backed up fails : ', error); @@ -127,19 +128,14 @@ export class IntervalDAO implements DAO { .connection(TABLE_NAME_INTERVALS) .select('id', 'screenshots', 'startedAt as recordedAt') .where('employeeId', user.employeeId) - .andWhere((qb) => - qb - .whereNot('screenshots', '[]') - .orWhereRaw(query(this._providerFactory.dialect)) - ) + .where('isDeleted', false) + .andWhere((qb) => qb.whereNot('screenshots', '[]').orWhereRaw(query(this._providerFactory.dialect))) .orderBy('id', 'desc') .limit(10); return latests.map((latest) => { return { ...latest, - screenshots: this._isJSON(latest.screenshots) - ? JSON.parse(latest.screenshots) - : latest.screenshots, + screenshots: this._isJSON(latest.screenshots) ? JSON.parse(latest.screenshots) : latest.screenshots }; }); } catch (error) { @@ -147,15 +143,6 @@ export class IntervalDAO implements DAO { } } - private _isJSON(value: any): boolean { - try { - JSON.parse(value); - return true; - } catch (error) { - return false; - } - } - /** * It deletes all the intervals that are not synced and then returns the remoteIds of the intervals * that are synced @@ -186,31 +173,18 @@ export class IntervalDAO implements DAO { } /** - * It deletes all the intervals that are not synced and that are between the given dates + * It soft deletes all the intervals that are not synced and that are between the given dates * @param {Date} startedAt - Date, * @param {Date} stoppedAt - Date - the date when the user stopped working * @param {UserTO} user - UserTO */ - public async deleteLocallyIdlesTime( - startedAt: Date, - stoppedAt: Date, - user: UserTO - ): Promise { + public async deleteLocallyIdlesTime(startedAt: Date, stoppedAt: Date, user: UserTO): Promise { try { - const subQuery = await this._provider - .connection(TABLE_NAME_INTERVALS) - .select('id') - .where('employeeId', user.employeeId) - .where((qb) => - qb.whereBetween('stoppedAt', [new Date(startedAt), new Date(stoppedAt)]) - ); await this._provider .connection(TABLE_NAME_INTERVALS) - .whereIn( - 'id', - subQuery.map(({ id }) => id) - ) - .del(); + .where('employeeId', user.employeeId) + .whereBetween('stoppedAt', [new Date(startedAt), new Date(stoppedAt)]) + .update({ isDeleted: true }); } catch (error) { console.log('[dao]: ', error); } @@ -218,19 +192,23 @@ export class IntervalDAO implements DAO { public async deleteByRemoteId(remoteId: string): Promise { try { - return await this._provider.connection(TABLE_NAME_INTERVALS).where('remoteId', remoteId).del(); + return await this._provider + .connection(TABLE_NAME_INTERVALS) + .where('remoteId', remoteId) + .update({ isDeleted: true }); } catch (error) { console.log('[dao]: ', 'interval deleted fails : ', error); } } public async lastSyncedInterval(employeeId: string): Promise { - const [interval] = await this._provider + return this._provider .connection(TABLE_NAME_INTERVALS) .where('employeeId', employeeId) - .whereNotNull('remoteId') + .where((builder) => { + builder.whereNotNull('remoteId').andWhere('synced', true).andWhere('isDeleted', false); + }) .orderBy('id', 'desc') - .limit(1); - return interval; + .first(); } } From a40057691877d717d9ecfbc86d44b0c6a233a7c0 Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:08:18 +0200 Subject: [PATCH 3/8] refactor: Interval model to include isDeleted flag Add isDeleted flag to the Interval model for improved tracking of deleted intervals. This enhancement facilitates better management of interval states. ever-co/ever-gauzy-desktop#44 --- .../src/lib/offline/models/interval.model.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/desktop-libs/src/lib/offline/models/interval.model.ts b/packages/desktop-libs/src/lib/offline/models/interval.model.ts index f5a019b948b..d0994b03626 100644 --- a/packages/desktop-libs/src/lib/offline/models/interval.model.ts +++ b/packages/desktop-libs/src/lib/offline/models/interval.model.ts @@ -1,5 +1,5 @@ import { Serializable } from '../../interfaces'; -import { IntervalTO } from '../dto/interval.dto'; +import { IntervalTO } from '../dto'; import { Base } from './base.model'; export class Interval @@ -19,6 +19,7 @@ export class Interval private _stoppedAt: Date; private _synced: boolean; private _timerId: number; + private _isDeleted: boolean; constructor(interval: IntervalTO) { super( @@ -41,6 +42,14 @@ export class Interval this._synced = interval.synced; } + public get isDeleted(): boolean { + return this._isDeleted; + } + + public set isDeleted(value: boolean) { + this._isDeleted = value; + } + public get timerId(): number { return this._timerId; } @@ -122,6 +131,7 @@ export class Interval } public toObject(): IntervalTO { return { + isDeleted: this._isDeleted, activities: this._activities, screenshots: this._screenshots, startedAt: this._startedAt, From e75f76cb714f7c41d4e7ed4ecdb8136de8ce77ad Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:09:19 +0200 Subject: [PATCH 4/8] feat: Include non-deleted intervals in timer query Add condition to include non-deleted intervals in timer query. This ensures all relevant intervals are fetched for the timers. ever-co/ever-gauzy-desktop#44 --- packages/desktop-libs/src/lib/offline/dao/timer.dao.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/desktop-libs/src/lib/offline/dao/timer.dao.ts b/packages/desktop-libs/src/lib/offline/dao/timer.dao.ts index 69435decb92..fd51b1472f3 100644 --- a/packages/desktop-libs/src/lib/offline/dao/timer.dao.ts +++ b/packages/desktop-libs/src/lib/offline/dao/timer.dao.ts @@ -82,6 +82,7 @@ export class TimerDAO implements DAO { `${TABLE_NAME_INTERVALS}.timerId` ) .where(`${TABLE_NAME_INTERVALS}.synced`, false) + .andWhere(`${TABLE_NAME_INTERVALS}.isDeleted`, false) .andWhere(`${TABLE_NAME_TIMERS}.employeeId`, user.employeeId) .andWhere((qb) => qb @@ -140,7 +141,7 @@ export class TimerDAO implements DAO { .andWhere(`${TABLE_NAME_TIMERS}.synced`, true) .orderBy(`${TABLE_NAME_TIMERS}.id`, 'asc'); - const timersWithIntervals = timers.map((timer: TimerTO) => ({ + return timers.map((timer: TimerTO) => ({ timer, intervals: intervals .map((interval: IntervalTO) => ({ @@ -152,8 +153,6 @@ export class TimerDAO implements DAO { (interval: IntervalTO) => interval.timerId === timer.id ), })); - - return timersWithIntervals } public async findFailedRuns(user: UserTO): Promise { From 53379964163fdbc39471ea6cdaa23e1318e405e0 Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:10:31 +0200 Subject: [PATCH 5/8] feat(migrate): add 'isDeleted' column to intervals table This change adds a new boolean column named 'isDeleted' with a default value of false to the intervals table. This alteration allows for easier management of deleted intervals. The corresponding down function drops the 'isDeleted' column when the migration needs to be reverted. ever-co/ever-gauzy-desktop#44 --- .../20240203094747_alter-table-interval.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 packages/desktop-libs/src/lib/offline/databases/migrations/20240203094747_alter-table-interval.ts diff --git a/packages/desktop-libs/src/lib/offline/databases/migrations/20240203094747_alter-table-interval.ts b/packages/desktop-libs/src/lib/offline/databases/migrations/20240203094747_alter-table-interval.ts new file mode 100644 index 00000000000..10c0277d1a2 --- /dev/null +++ b/packages/desktop-libs/src/lib/offline/databases/migrations/20240203094747_alter-table-interval.ts @@ -0,0 +1,17 @@ +import { Knex } from 'knex'; +import { TABLE_NAME_INTERVALS } from '../../dto'; + +export async function up(knex: Knex): Promise { + return knex.schema.alterTable(TABLE_NAME_INTERVALS, function (table) { + // Add a new boolean column named 'isDeleted' with default value false + table.boolean('isDeleted').defaultTo(false); + }); +} + +export async function down(knex: Knex): Promise { + return knex.schema.alterTable(TABLE_NAME_INTERVALS, function (table) { + // Drop the 'isDeleted' column if the migration needs to be reverted + table.dropColumn('isDeleted'); + }); +} + From 1717b6ffb34c38b7334bba1dd91b2005cad7f766 Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:11:35 +0200 Subject: [PATCH 6/8] refactor: interval, timer, and user services Refactor interval, timer, and user services to handle empty or invalid data, and to improve error reporting. This ensures more robust and user-friendly data handling. ever-co/ever-gauzy-desktop#44 --- .../lib/offline/services/interval.service.ts | 68 +++++++++++-------- .../src/lib/offline/services/timer.service.ts | 27 +++++++- .../src/lib/offline/services/user.service.ts | 12 +++- 3 files changed, 72 insertions(+), 35 deletions(-) diff --git a/packages/desktop-libs/src/lib/offline/services/interval.service.ts b/packages/desktop-libs/src/lib/offline/services/interval.service.ts index 3c1ab943bdc..4598f2fed39 100644 --- a/packages/desktop-libs/src/lib/offline/services/interval.service.ts +++ b/packages/desktop-libs/src/lib/offline/services/interval.service.ts @@ -19,15 +19,20 @@ export class IntervalService implements IIntervalService { this._timerService = new TimerService(); this._offlineMode = DesktopOfflineModeHandler.instance; } + public async create(interval: IntervalTO): Promise { try { + if (!interval) { + return console.error('WARN[INTERVAL_SERVICE]: Without data interval cannot be created'); + } interval.activities = JSON.stringify(interval.activities); interval.screenshots = JSON.stringify(interval.screenshots) as any; await this._intervalDAO.save(interval); } catch (error) { - throw new AppError('INTERVALSRVCE', error); + throw new AppError('[INTERVAL_SERVICE]', error); } } + public async backedUpNoSynced(): Promise { try { const user = await this._userService.retrieve(); @@ -41,31 +46,33 @@ export class IntervalService implements IIntervalService { return []; } } + public async destroy(interval: Partial): Promise { try { + if (!interval) { + return console.error('WARN[INTERVAL_SERVICE]: Without data interval cannot be destroyed'); + } await this._intervalDAO.delete(interval); } catch (error) { - throw new AppError('INTERVALSRVCE', error); + throw new AppError('[INTERVAL_SERVICE]', error); } } + public async synced(interval: IntervalTO): Promise { try { + if (!interval) { + return console.error('WARN[INTERVAL_SERVICE]: Without data interval cannot be synced'); + } const intervalToUpdate = new Interval(interval); intervalToUpdate.synced = true; - intervalToUpdate.activities = JSON.stringify( - intervalToUpdate.activities - ); - intervalToUpdate.screenshots = JSON.stringify( - intervalToUpdate.screenshots - ) as any; - await this._intervalDAO.update( - intervalToUpdate.id, - intervalToUpdate.toObject() - ); + intervalToUpdate.activities = JSON.stringify(intervalToUpdate.activities); + intervalToUpdate.screenshots = JSON.stringify(intervalToUpdate.screenshots) as any; + await this._intervalDAO.update(intervalToUpdate.id, intervalToUpdate.toObject()); } catch (error) { - throw new AppError('INTERVALSRVCE', error); + throw new AppError('[INTERVAL_SERVICE]', error); } } + public async backedUpAllNoSynced(): Promise { try { const user = await this._userService.retrieve(); @@ -75,6 +82,7 @@ export class IntervalService implements IIntervalService { return []; } } + public async countNoSynced(): Promise { try { const user = await this._userService.retrieve(); @@ -86,6 +94,7 @@ export class IntervalService implements IIntervalService { return 0; } } + public async screenshots(): Promise { try { const user = await this._userService.retrieve(); @@ -96,24 +105,19 @@ export class IntervalService implements IIntervalService { } } - public async removeIdlesTime( - startedAt: Date, - stoppedAt: Date - ): Promise { + public async removeIdlesTime(startedAt: Date, stoppedAt: Date): Promise { try { + if (!startedAt || !stoppedAt) { + console.error( + `WARN[INTERVAL_SERVICE]: Without startedAt or stoppedAt dates, we cannot remove idles time` + ); + return []; + } const user = await this._userService.retrieve(); let remoteIds = []; this._offlineMode.enabled - ? await this._intervalDAO.deleteLocallyIdlesTime( - startedAt, - stoppedAt, - user - ) - : (remoteIds = await this._intervalDAO.deleteIdlesTime( - startedAt, - stoppedAt, - user - )); + ? await this._intervalDAO.deleteLocallyIdlesTime(startedAt, stoppedAt, user) + : (remoteIds = await this._intervalDAO.deleteIdlesTime(startedAt, stoppedAt, user)); return remoteIds.map(({ remoteId }) => remoteId); } catch (error) { console.error(error); @@ -127,17 +131,23 @@ export class IntervalService implements IIntervalService { */ public async remove(id: number): Promise { try { + if (!id || typeof id !== 'number') { + return console.error('WARN[INTERVAL_SERVICE]: No interval id, cannot remove'); + } await this._intervalDAO.delete({ id }); } catch (error) { - throw new AppError('INTERVALSRVCE', error); + throw new AppError('[INTERVAL_SERVICE]', error); } } public async removeByRemoteId(remoteId: string): Promise { try { + if (!remoteId || typeof remoteId !== 'string') { + return console.error('WARN[INTERVAL_SERVICE]: No interval remoteId, cannot remove'); + } await this._intervalDAO.deleteByRemoteId(remoteId); } catch (error) { - throw new AppError('INTERVALSRVCE', error); + throw new AppError('[INTERVAL_SERVICE]', error); } } diff --git a/packages/desktop-libs/src/lib/offline/services/timer.service.ts b/packages/desktop-libs/src/lib/offline/services/timer.service.ts index 4086bc36c54..28d0a07ab47 100644 --- a/packages/desktop-libs/src/lib/offline/services/timer.service.ts +++ b/packages/desktop-libs/src/lib/offline/services/timer.service.ts @@ -11,6 +11,7 @@ export class TimerService implements ITimerService { this._timerDAO = new TimerDAO(); this._userService = new UserService(); } + public async findLastOne(): Promise { try { const user = await this._userService.retrieve(); @@ -20,6 +21,7 @@ export class TimerService implements ITimerService { return null; } } + public async findLastCapture(): Promise { try { const user = await this._userService.retrieve(); @@ -29,13 +31,18 @@ export class TimerService implements ITimerService { return null; } } + public async update(timer: Partial): Promise { try { + if (!timer && !timer.id) { + return console.error('WARN[TIMER_SERVICE]: No timer data, cannot update'); + } await this._timerDAO.update(timer.id, timer.toObject()); } catch (error) { - throw new AppError('TMRSRVCE', error); + throw new AppError('[TIMER_SERVICE]', error); } } + public async findAll(): Promise { try { return await this._timerDAO.findAll(); @@ -44,27 +51,41 @@ export class TimerService implements ITimerService { return []; } } + public async findById(timer: Partial): Promise { try { + if (!timer && !timer.id) { + console.error('WARN[TIMER_SERVICE]: No timer data, cannot find'); + return null; + } return await this._timerDAO.findOneById(timer.id); } catch (error) { console.error(error); return null; } } + public async remove(timer: Partial): Promise { try { + if (!timer) { + console.error('WARN[TIMER_SERVICE]: No timer data, cannot remove'); + return null; + } await this._timerDAO.delete(timer); } catch (error) { - throw new AppError('TMRSRVCE', error); + throw new AppError('[TIMER_SERVICE]', error); } } public async save(timer: Timer): Promise { try { + if (!timer) { + console.error('WARN[TIMER_SERVICE]: No timer data, cannot save'); + return null; + } await this._timerDAO.save(timer.toObject()); } catch (error) { - throw new AppError('TMRSRVCE', error); + throw new AppError('[TIMER_SERVICE]', error); } } diff --git a/packages/desktop-libs/src/lib/offline/services/user.service.ts b/packages/desktop-libs/src/lib/offline/services/user.service.ts index 76cce869bff..e58dbccf54a 100644 --- a/packages/desktop-libs/src/lib/offline/services/user.service.ts +++ b/packages/desktop-libs/src/lib/offline/services/user.service.ts @@ -13,17 +13,23 @@ export class UserService implements IUserService { public async save(user: UserTO): Promise { try { + if (!user) { + return console.error('WARN[USER_SERVICE]: No user data, cannot save'); + } await this._userDAO.save(user); } catch (error) { - throw new AppError('USERSRVCE', error); + throw new AppError('USER_SERVICE', error); } } public async update(user: Partial): Promise { try { + if (!user && !user.id) { + return console.error('WARN[USER_SERVICE]: No user data, cannot update'); + } await this._userDAO.update(user.id, user); } catch (error) { - throw new AppError('USERSRVCE', error); + throw new AppError('USER_SERVICE', error); } } @@ -43,7 +49,7 @@ export class UserService implements IUserService { try { await this._userDAO.delete(); } catch (error) { - throw new AppError('USERSRVCE', error); + throw new AppError('USER_SERVICE', error); } } } From cdbe39dd90b2d4ad1676697e2818a99596f59e99 Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:13:14 +0200 Subject: [PATCH 7/8] refactor: time logs handling in time tracker component Add a check for empty time logs array before sending data to the backend to prevent errors and improve data reliability. This update enhances the robustness of the time tracking feature. ever-co/ever-gauzy-desktop#44 --- .../src/lib/time-tracker/time-tracker.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/desktop-ui-lib/src/lib/time-tracker/time-tracker.component.ts b/packages/desktop-ui-lib/src/lib/time-tracker/time-tracker.component.ts index 6a02782f330..6ab0c408393 100644 --- a/packages/desktop-ui-lib/src/lib/time-tracker/time-tracker.component.ts +++ b/packages/desktop-ui-lib/src/lib/time-tracker/time-tracker.component.ts @@ -2328,11 +2328,16 @@ export class TimeTrackerComponent implements OnInit, AfterViewInit { await callBack(); } const timeLogs = resActivities.timeLogs; + if (!timeLogs?.length) { + // Stop process if there is no time logs associate to activity result. + console.error('[@SendActivities]', 'No time logs'); + return; + } this.electronService.ipcRenderer.send('return_time_slot', { timerId: arg.timerId, timeSlotId: resActivities.id, quitApp: arg.quitApp, - timeLogs: timeLogs, + timeLogs: timeLogs }); this.electronService.ipcRenderer.send('remove_aw_local_data'); this.electronService.ipcRenderer.send( From d1c8b771e7c4ef49a09e496eade9b6e49576bcf4 Mon Sep 17 00:00:00 2001 From: adkif <45813955+adkif@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:49:22 +0200 Subject: [PATCH 8/8] fix: deepscan --- .../desktop-libs/src/lib/offline/services/timer.service.ts | 4 ++-- .../desktop-libs/src/lib/offline/services/user.service.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/desktop-libs/src/lib/offline/services/timer.service.ts b/packages/desktop-libs/src/lib/offline/services/timer.service.ts index 28d0a07ab47..98cdd4bc426 100644 --- a/packages/desktop-libs/src/lib/offline/services/timer.service.ts +++ b/packages/desktop-libs/src/lib/offline/services/timer.service.ts @@ -34,7 +34,7 @@ export class TimerService implements ITimerService { public async update(timer: Partial): Promise { try { - if (!timer && !timer.id) { + if (!timer.id) { return console.error('WARN[TIMER_SERVICE]: No timer data, cannot update'); } await this._timerDAO.update(timer.id, timer.toObject()); @@ -54,7 +54,7 @@ export class TimerService implements ITimerService { public async findById(timer: Partial): Promise { try { - if (!timer && !timer.id) { + if (!timer.id) { console.error('WARN[TIMER_SERVICE]: No timer data, cannot find'); return null; } diff --git a/packages/desktop-libs/src/lib/offline/services/user.service.ts b/packages/desktop-libs/src/lib/offline/services/user.service.ts index e58dbccf54a..a4c5a751597 100644 --- a/packages/desktop-libs/src/lib/offline/services/user.service.ts +++ b/packages/desktop-libs/src/lib/offline/services/user.service.ts @@ -24,7 +24,7 @@ export class UserService implements IUserService { public async update(user: Partial): Promise { try { - if (!user && !user.id) { + if (!user.id) { return console.error('WARN[USER_SERVICE]: No user data, cannot update'); } await this._userDAO.update(user.id, user);