Skip to content

Commit fe2625e

Browse files
evereqdependabot[bot]syns2191
authored
Stage (#9196)
* Merge pull request #9183 from ever-co/dependabot/npm_and_yarn/typeorm-0.3.26 chore(deps): bump typeorm from 0.3.24 to 0.3.27 * fix: desktop-timer error message, offline timer (#9180) * fix: desktop-timer error message, offline timer * fix: cspell Behaviour * fix: missing startedAt while update timer status synced * fix: adding manual timelog when timer started and stopped in offline mode and already have another starting timer * style: remove unused code * fix: handle another condition offline timer * fix: remove unnecessary options * fix: change error plain text to internationalization * fix: rename key and added NETWOR_ERROR translation --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: syns <[email protected]>
2 parents b6ff4ef + 10cc488 commit fe2625e

File tree

44 files changed

+470
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+470
-163
lines changed

.cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,8 @@
720720
"soundshot",
721721
"soundshots",
722722
"runtimes",
723-
"localtime"
723+
"localtime",
724+
"Behaviour"
724725
],
725726
"useGitignore": true,
726727
"ignorePaths": [

apps/desktop-timer/src/assets/styles/_overrides.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,3 +735,13 @@ angular2-smart-table > div {
735735
angular2-smart-table a:hover {
736736
text-decoration: auto !important;
737737
}
738+
739+
nb-toastr-container {
740+
position: absolute !important;
741+
top: 20px !important; /* change this value to what you want */
742+
right: 0px !important; /* keep consistent with your toast position */
743+
}
744+
745+
nb-toast {
746+
width: 21rem !important;
747+
}

apps/desktop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"sound-play": "1.1.0",
8585
"squirrelly": "^8.0.8",
8686
"twing": "^5.0.2",
87-
"typeorm": "^0.3.24",
87+
"typeorm": "^0.3.27",
8888
"undici": "^6.10.2",
8989
"custom-electron-titlebar": "^4.2.8"
9090
},

apps/server-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"rxjs": "^7.8.2",
8383
"squirrelly": "^8.0.8",
8484
"twing": "^5.0.2",
85-
"typeorm": "^0.3.24",
85+
"typeorm": "^0.3.27",
8686
"undici": "^6.10.2",
8787
"custom-electron-titlebar": "^4.2.8"
8888
},

apps/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"rxjs": "^7.8.2",
7979
"squirrelly": "^8.0.8",
8080
"twing": "^5.0.2",
81-
"typeorm": "^0.3.24",
81+
"typeorm": "^0.3.27",
8282
"undici": "^6.10.2",
8383
"custom-electron-titlebar": "^4.2.8"
8484
},

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"graphql": "^16.11.0",
3838
"nest-knexjs": "^0.0.26",
3939
"slugify": "^1.6.6",
40-
"typeorm": "^0.3.24",
40+
"typeorm": "^0.3.27",
4141
"tslib": "^2.6.2"
4242
},
4343
"devDependencies": {

packages/config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"mikro-orm-soft-delete": "^1.0.0-alpha.1",
4646
"nest-knexjs": "^0.0.26",
4747
"tslib": "^2.6.2",
48-
"typeorm": "^0.3.24"
48+
"typeorm": "^0.3.27"
4949
},
5050
"devDependencies": {
5151
"@types/jest": "29.5.14",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"sql.js": "^1.5.0",
177177
"streamifier": "^0.1.1",
178178
"swagger-ui-express": "^5.0.0",
179-
"typeorm": "^0.3.24",
179+
"typeorm": "^0.3.27",
180180
"underscore": "^1.13.3",
181181
"unleash-client": "^3.16.1",
182182
"unzipper": "^0.10.11",

packages/desktop-ui-lib/src/lib/interceptors/unauthorized.interceptor.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ import { catchError } from 'rxjs/operators';
55
import { AuthStrategy } from '../auth';
66
import { ElectronService } from '../electron/services';
77
import { Router } from '@angular/router';
8-
import { Store } from '../services';
8+
import { Store, ErrorMapping } from '../services';
99

1010
@Injectable()
1111
export class UnauthorizedInterceptor implements HttpInterceptor {
1212
constructor(
1313
private authStrategy: AuthStrategy,
1414
private electronService: ElectronService,
1515
private router: Router,
16-
private store: Store
17-
) {}
16+
private store: Store,
17+
private _errorMapping: ErrorMapping
18+
) { }
1819

1920
intercept(
2021
request: HttpRequest<any>,
@@ -24,7 +25,10 @@ export class UnauthorizedInterceptor implements HttpInterceptor {
2425
catchError((error) => {
2526
// Early return if offline is triggered.
2627
if (this.store.isOffline) {
27-
return;
28+
return throwError(() => {
29+
const message = this._errorMapping.mapErrorMessage(error);
30+
return new Error(message);
31+
});
2832
}
2933
// Unauthorized error occurred
3034
if (error.status === HttpStatusCode.Unauthorized) {
@@ -39,7 +43,8 @@ export class UnauthorizedInterceptor implements HttpInterceptor {
3943
})
4044
);
4145
}
42-
return throwError(() => error);
46+
47+
return throwError(() => new Error(this._errorMapping.mapErrorMessage(error)));
4348
})
4449
);
4550
}

packages/desktop-ui-lib/src/lib/offline-sync/concretes/sequence-queue.ts

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ export class SequenceQueue extends OfflineQueue<ISequence> {
4747

4848
let latest = null;
4949

50-
if (timer.isStartedOffline) {
50+
if (timer.isStartedOffline && timer.timelogId) {
51+
latest = await this._timeTrackerService.getTimeLogById(timer.timelogId);
52+
} else if (timer.isStartedOffline && !timer.stoppedAt) {
5153
console.log('⏱ - Silent start');
5254
latest = await this._timeTrackerService.toggleApiStart({
5355
...timer,
5456
...params
5557
});
58+
} else if (timer.isStartedOffline && !timer.timelogId && timer.startedAt && timer.stoppedAt) {
59+
latest = await this._timeTrackerService.addTimeLog({
60+
startedAt: timer.startedAt,
61+
stoppedAt: timer.stoppedAt,
62+
taskId: timer.taskId,
63+
projectId: timer.projectId,
64+
description: timer.description
65+
});
5666
}
5767

5868
console.log('🛠 - Create queue');
@@ -78,10 +88,31 @@ export class SequenceQueue extends OfflineQueue<ISequence> {
7888

7989
if (timer.isStoppedOffline) {
8090
console.log('⏱ - Silent stop');
81-
latest = await this._timeTrackerService.toggleApiStop({
82-
...timer,
83-
...params
84-
});
91+
if (!latest && timer.timelogId) {
92+
const currentTimeLog = await this._timeTrackerService.getTimeLogById(timer.timelogId);
93+
if (currentTimeLog.id && currentTimeLog.isRunning) {
94+
latest = await this._timeTrackerService.toggleApiStop({
95+
...timer,
96+
...params
97+
});
98+
} else if (currentTimeLog.id && timer.stoppedAt) {
99+
latest = await this._timeTrackerService.updateTimeLog(
100+
timer.timelogId,
101+
{
102+
startedAt: timer.startedAt || currentTimeLog.startedAt,
103+
stoppedAt: timer.stoppedAt,
104+
description: timer.description,
105+
projectId: timer.projectId,
106+
taskId: timer.taskId
107+
}
108+
)
109+
}
110+
} else if (latest && latest.id && latest.isRunning) {
111+
latest = await this._timeTrackerService.toggleApiStop({
112+
...timer,
113+
...params
114+
});
115+
}
85116
}
86117

87118
const status = await this._timeTrackerStatusService.status();
@@ -92,9 +123,9 @@ export class SequenceQueue extends OfflineQueue<ISequence> {
92123
lastTimer: latest
93124
? latest
94125
: {
95-
...timer,
96-
id: status?.lastLog?.id
97-
},
126+
...timer,
127+
id: status?.lastLog?.id
128+
},
98129
...timer
99130
});
100131
console.log('⏱ - local database updated');

0 commit comments

Comments
 (0)