-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- floating buttons changed to normal icon buttons and tooltip with text added - added a label in the wishlist list to indicate that the wishlist is shared - fixed the problems when the wishlist is no longer shared -> redirect to error page - fixed the problem with duplicate requests - added a separate state for the shared wishlist so that logged in users can use the link to the shared wishlist
- Loading branch information
1 parent
38f69b4
commit c02dfbc
Showing
10 changed files
with
130 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 28 additions & 13 deletions
41
src/app/extensions/wishlists/guards/fetch-shared-wishlist.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
import { inject } from '@angular/core'; | ||
import { ActivatedRouteSnapshot } from '@angular/router'; | ||
import { Store } from '@ngrx/store'; | ||
import { Observable } from 'rxjs'; | ||
import { map, tap } from 'rxjs/operators'; | ||
import { Store, select } from '@ngrx/store'; | ||
import { Observable, of } from 'rxjs'; | ||
import { map, switchMap, tap } from 'rxjs/operators'; | ||
|
||
import { wishlistActions } from '../store/wishlist'; | ||
import { isSharedWishlistLoaded, isSharedWishlistLoading, wishlistActions } from '../store/wishlist'; | ||
|
||
/** | ||
* Fetch the shared wishlist | ||
*/ | ||
export function fetchSharedWishlistGuard(route: ActivatedRouteSnapshot): boolean | Observable<boolean> { | ||
const store = inject(Store); | ||
const wishlistId = route.params.wishlistId; | ||
const owner = route.queryParams.owner; | ||
const secureCode = route.queryParams.secureCode; | ||
|
||
return store.pipe( | ||
tap(() => { | ||
store.dispatch( | ||
wishlistActions.loadSharedWishlist({ | ||
wishlistId: route.params.wishlistId, | ||
owner: route.queryParams.owner, | ||
secureCode: route.queryParams.secureCode, | ||
}) | ||
select(isSharedWishlistLoaded(wishlistId)), | ||
switchMap(loaded => { | ||
if (loaded) { | ||
return of(true); | ||
} | ||
|
||
return store.pipe( | ||
select(isSharedWishlistLoading(wishlistId)), | ||
tap(loading => { | ||
if (!loading) { | ||
store.dispatch( | ||
wishlistActions.loadSharedWishlist({ | ||
wishlistId, | ||
owner, | ||
secureCode, | ||
}) | ||
); | ||
} | ||
}), | ||
map(() => true) | ||
); | ||
}), | ||
map(() => true) | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/app/extensions/wishlists/pages/shared-wishlist/shared-wishlist-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 16 additions & 7 deletions
23
src/app/extensions/wishlists/pages/shared-wishlist/shared-wishlist-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters