Skip to content

Commit

Permalink
resources: smoother snackbar (fixes #7954)(fixes #7955) (#7956)
Browse files Browse the repository at this point in the history
Co-authored-by: Mutugi <48474421+Mutugiii@users.noreply.github.com>
Co-authored-by: dogi <dogi@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent ad4790a commit 5dbc0bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.16.16",
"version": "0.16.17",
"myplanet": {
"latest": "v0.21.45",
"min": "v0.20.45"
Expand Down
3 changes: 2 additions & 1 deletion src/app/courses/courses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ export class CoursesService {
courseAdmissionMany(courseIds, type) {
return this.userService.changeShelf(courseIds, 'courseIds', type).pipe(map(({ shelf, countChanged }) => {
const prefix = countChanged > 1 ? $localize`${countChanged} courses` : this.getCourseNameFromId(courseIds[courseIds.length - 1]);
const message = type === 'remove' ? $localize`${prefix} successfully removed from myCourses` : $localize`${prefix} added to your dashboard`;
const message = type === 'remove' ? $localize`${prefix} successfully removed from myCourses` :
$localize`${prefix} added to myCourses`;
this.planetMessageService.showMessage(message);
return shelf;
}));
Expand Down
7 changes: 6 additions & 1 deletion src/app/resources/resources.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ export class ResourcesService {

libraryAddRemove(resourceIds, type) {
return this.userService.changeShelf(resourceIds, 'resourceIds', type).pipe(map(({ shelf, countChanged }) => {
const resource = this.resources.local.find(r => r._id === resourceIds[0]);
const resourceTitle = resource ? resource.doc.title : '';
const message = type === 'remove' ?
countChanged + $localize` Resources successfully removed from myLibrary` : countChanged + $localize` Resources added to your dashboard`;
(countChanged === 1 ? $localize`${resourceTitle} successfully removed from myLibrary` :
`${countChanged} ${$localize`Resources`} successfully removed from myLibrary`) :
(countChanged === 1 ? $localize`${resourceTitle} added to myLibrary` :
`${countChanged} ${$localize`Resources`} added to myLibrary`);
this.planetMessageService.showMessage(message);
return shelf;
}));
Expand Down

0 comments on commit 5dbc0bd

Please sign in to comment.