feedtack 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.js +24 -3
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -503,6 +503,26 @@ function useFeedtackState({
|
|
|
503
503
|
onError
|
|
504
504
|
}) {
|
|
505
505
|
useFeedtackDom(theme);
|
|
506
|
+
const [pathname, setPathname] = useState2(() => window.location.pathname);
|
|
507
|
+
useEffect3(() => {
|
|
508
|
+
const update = () => setPathname(window.location.pathname);
|
|
509
|
+
const origPush = history.pushState.bind(history);
|
|
510
|
+
const origReplace = history.replaceState.bind(history);
|
|
511
|
+
history.pushState = (...args) => {
|
|
512
|
+
origPush(...args);
|
|
513
|
+
update();
|
|
514
|
+
};
|
|
515
|
+
history.replaceState = (...args) => {
|
|
516
|
+
origReplace(...args);
|
|
517
|
+
update();
|
|
518
|
+
};
|
|
519
|
+
window.addEventListener("popstate", update);
|
|
520
|
+
return () => {
|
|
521
|
+
window.removeEventListener("popstate", update);
|
|
522
|
+
history.pushState = origPush;
|
|
523
|
+
history.replaceState = origReplace;
|
|
524
|
+
};
|
|
525
|
+
}, []);
|
|
506
526
|
const [comment, setComment] = useState2("");
|
|
507
527
|
const [sentiment, setSentiment] = useState2(null);
|
|
508
528
|
const [commentError, setCommentError] = useState2(false);
|
|
@@ -525,8 +545,8 @@ function useFeedtackState({
|
|
|
525
545
|
});
|
|
526
546
|
useEffect3(() => {
|
|
527
547
|
setLoading(true);
|
|
528
|
-
adapter.loadFeedback({ pathname
|
|
529
|
-
}, [adapter, onError]);
|
|
548
|
+
adapter.loadFeedback({ pathname }).then(setFeedbackItems).catch((err) => onError?.(err)).finally(() => setLoading(false));
|
|
549
|
+
}, [adapter, onError, pathname]);
|
|
530
550
|
const updateItem = (id, fn) => setFeedbackItems(
|
|
531
551
|
(prev) => prev.map((i) => i.payload.id === id ? fn(i) : i)
|
|
532
552
|
);
|
|
@@ -635,6 +655,7 @@ function useFeedtackState({
|
|
|
635
655
|
commentError,
|
|
636
656
|
setCommentError,
|
|
637
657
|
submitting,
|
|
658
|
+
pathname,
|
|
638
659
|
feedbackItems,
|
|
639
660
|
loading,
|
|
640
661
|
openThreadId,
|
|
@@ -797,7 +818,7 @@ function FeedtackProvider({
|
|
|
797
818
|
]
|
|
798
819
|
}
|
|
799
820
|
),
|
|
800
|
-
!state.loading && state.feedbackItems.filter((item) => !state.isArchivedForUser(item)).map((item) => {
|
|
821
|
+
!state.loading && state.feedbackItems.filter((item) => item.payload.page.pathname === state.pathname).filter((item) => !state.isArchivedForUser(item)).map((item) => {
|
|
801
822
|
const pin = item.payload.pins[0];
|
|
802
823
|
return /* @__PURE__ */ jsx2(
|
|
803
824
|
"button",
|