Browse Source

update toast close and add bookmarkInfo to BookmarkButton

Mudana-Grune 3 years ago
parent
commit
445ebee91c

+ 3 - 5
packages/app/src/components/BookmarkButtons.tsx

@@ -7,9 +7,8 @@ import {
   UncontrolledTooltip, Popover, PopoverBody, DropdownToggle,
 } from 'reactstrap';
 
-import { useSWRBookmarkInfo } from '~/stores/bookmark';
+import { IBookmarkInfo } from '~/interfaces/bookmark-info';
 import { useIsGuestUser } from '~/stores/context';
-import { useSWRxCurrentPage } from '~/stores/page';
 
 import { IUser } from '../interfaces/user';
 
@@ -21,14 +20,13 @@ import styles from './BookmarkButtons.module.scss';
 interface Props {
   bookmarkedUsers?: IUser[]
   hideTotalNumber?: boolean
+  bookmarkInfo? : IBookmarkInfo
 }
 
 const BookmarkButtons: FC<Props> = (props: Props) => {
   const { t } = useTranslation();
-  const { data } = useSWRxCurrentPage();
-  const { data: bookmarkInfo } = useSWRBookmarkInfo(data?._id);
   const {
-    bookmarkedUsers, hideTotalNumber,
+    bookmarkedUsers, hideTotalNumber, bookmarkInfo,
   } = props;
 
   const [isPopoverOpen, setIsPopoverOpen] = useState(false);

+ 1 - 0
packages/app/src/components/Navbar/SubNavButtons.tsx

@@ -230,6 +230,7 @@ const SubNavButtonsSubstance = (props: SubNavButtonsSubstanceProps): JSX.Element
         <BookmarkButtons
           hideTotalNumber={isCompactMode}
           bookmarkedUsers={bookmarkInfo?.bookmarkedUsers}
+          bookmarkInfo={bookmarkInfo}
         />
       )}
       {revisionId != null && !isCompactMode && (

+ 10 - 6
packages/app/test/cypress/integration/20-basic-features/20-basic-features--click-page-icons.spec.ts

@@ -97,9 +97,11 @@ context('Click page icons button', () => {
     cy.get('#bookmark-dropdown-btn').should('have.class', 'active');
 
     // Close toaster
-    cy.get('.Toastify__toast').should('be.visible').within(() => {
-      cy.get('.Toastify__close-button').should('be.visible').click();
-      cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
+    cy.get('.Toastify__toast').should('be.visible').then(toast => {
+      cy.wrap(toast).within(() => {
+        cy.get('.Toastify__close-button').should('be.visible').click();
+        cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
+      });
     });
 
     // position of the element is not fixed to be displayed, so the element is removed
@@ -132,9 +134,11 @@ context('Click page icons button', () => {
     cy.get('#bookmark-dropdown-btn').should('not.have.class', 'active');
 
     // Close toaster
-    cy.get('.Toastify__toast').should('be.visible').within(() => {
-      cy.get('.Toastify__close-button').should('be.visible').click();
-      cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
+    cy.get('.Toastify__toast').should('be.visible').then(toast => {
+      cy.wrap(toast).within(() => {
+        cy.get('.Toastify__close-button').should('be.visible').click();
+        cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
+      });
     });
 
     // position of the element is not fixed to be displayed, so the element is removed