@parallelworks/tandem-web 0.164.1 → 0.166.0
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/_virtual/_virtual_i18n/en/common.js +38 -3
- package/_virtual/_virtual_i18n/es/common.js +38 -3
- package/_virtual/_virtual_i18n/ja/common.js +38 -3
- package/_virtual/_virtual_i18n/ko/common.js +38 -3
- package/_virtual/_virtual_i18n/zh/common.js +38 -3
- package/api/mutations.js +6 -5
- package/components/ShortcutSheet.js +142 -0
- package/components/icons.js +2 -3
- package/lib/eachLimited.js +15 -0
- package/lib/issueMenu.js +148 -122
- package/lib/notificationRead.js +22 -0
- package/lib/notifications.js +66 -57
- package/lib/shortcutName.js +7 -0
- package/lib/shortcuts.js +14 -20
- package/package.json +1 -1
- package/pages/issues.js +309 -257
- package/pages/triage.js +2 -0
- package/routes/_workspace/notifications2.js +261 -218
- package/routes/_workspace2.js +413 -406
package/lib/notifications.js
CHANGED
|
@@ -1,75 +1,84 @@
|
|
|
1
1
|
import { basePath as e } from "./base.js";
|
|
2
2
|
import { api as t, unwrap as n } from "../api/client.js";
|
|
3
3
|
import { notificationsQuery as r, pushSettingsQuery as i } from "../api/queries.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { markRead as a } from "./notificationRead.js";
|
|
5
|
+
import { useCallback as o, useEffect as s, useRef as c, useState as l } from "react";
|
|
6
|
+
import { useTranslations as u } from "use-intl";
|
|
7
|
+
import { useMutation as d, useQuery as f, useQueryClient as p } from "@tanstack/react-query";
|
|
7
8
|
// src/lib/notifications.ts
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
|
|
9
|
+
async function m(e, t, n, i) {
|
|
10
|
+
let { queryKey: o } = r(t);
|
|
11
|
+
await e.cancelQueries({ queryKey: o });
|
|
12
|
+
let s = (/* @__PURE__ */ new Date()).toISOString();
|
|
13
|
+
e.setQueryData(o, (e) => e && a(e, n, i, s));
|
|
14
|
+
}
|
|
15
|
+
function h(e) {
|
|
16
|
+
let i = p();
|
|
17
|
+
return d({
|
|
11
18
|
mutationFn: async (r) => {
|
|
12
19
|
n(await t.POST("/api/v1/notifications/read", { body: {
|
|
13
20
|
workspace: e,
|
|
14
21
|
...r && { ids: r }
|
|
15
|
-
} })), await
|
|
22
|
+
} })), await x(r);
|
|
16
23
|
},
|
|
24
|
+
onMutate: (t) => m(i, e, t, !0),
|
|
17
25
|
onSettled: () => i.invalidateQueries({ queryKey: r(e).queryKey })
|
|
18
26
|
});
|
|
19
27
|
}
|
|
20
|
-
function
|
|
21
|
-
let i =
|
|
22
|
-
return
|
|
28
|
+
function g(e) {
|
|
29
|
+
let i = p();
|
|
30
|
+
return d({
|
|
23
31
|
mutationFn: async (r) => n(await t.POST("/api/v1/notifications/unread", { body: {
|
|
24
32
|
workspace: e,
|
|
25
33
|
ids: r
|
|
26
34
|
} })),
|
|
35
|
+
onMutate: (t) => m(i, e, t, !1),
|
|
27
36
|
onSettled: () => i.invalidateQueries({ queryKey: r(e).queryKey })
|
|
28
37
|
});
|
|
29
38
|
}
|
|
30
|
-
function
|
|
31
|
-
let i =
|
|
32
|
-
return
|
|
39
|
+
function _(e) {
|
|
40
|
+
let i = p();
|
|
41
|
+
return d({
|
|
33
42
|
mutationFn: async (r) => {
|
|
34
43
|
n(await t.POST("/api/v1/notifications/archive", { body: {
|
|
35
44
|
workspace: e,
|
|
36
45
|
...r && { ids: r }
|
|
37
|
-
} })), r && await
|
|
46
|
+
} })), r && await x(r);
|
|
38
47
|
},
|
|
39
48
|
onSettled: () => i.invalidateQueries({ queryKey: r(e).queryKey })
|
|
40
49
|
});
|
|
41
50
|
}
|
|
42
|
-
function
|
|
43
|
-
let { data: n } =
|
|
44
|
-
|
|
51
|
+
function v(e, t) {
|
|
52
|
+
let { data: n } = f(r(e)), { mutate: i } = h(e), a = c(/* @__PURE__ */ new Set()), o = t.toUpperCase(), l = (n?.notifications ?? []).filter((e) => !e.readAt && e.identifier.toUpperCase() === o && !a.current.has(e.id)).map((e) => e.id).join(",");
|
|
53
|
+
s(() => {
|
|
45
54
|
if (!l) return;
|
|
46
55
|
let e = l.split(",");
|
|
47
56
|
for (let t of e) a.current.add(t);
|
|
48
57
|
i(e);
|
|
49
58
|
}, [l, i]);
|
|
50
59
|
}
|
|
51
|
-
var
|
|
52
|
-
async function
|
|
53
|
-
if ("serviceWorker" in navigator) return navigator.serviceWorker.getRegistration(
|
|
60
|
+
var y = () => `${e}/`;
|
|
61
|
+
async function b() {
|
|
62
|
+
if ("serviceWorker" in navigator) return navigator.serviceWorker.getRegistration(y());
|
|
54
63
|
}
|
|
55
|
-
async function
|
|
56
|
-
let t = await
|
|
64
|
+
async function x(e) {
|
|
65
|
+
let t = await b();
|
|
57
66
|
for (let n of await t?.getNotifications() ?? []) (!e || e.includes(n.tag)) && n.close();
|
|
58
67
|
}
|
|
59
|
-
var
|
|
60
|
-
function
|
|
68
|
+
var S = () => typeof window < "u" && "serviceWorker" in navigator && "PushManager" in window && "Notification" in window;
|
|
69
|
+
function C(e) {
|
|
61
70
|
let t = e.replace(/-/g, "+").replace(/_/g, "/");
|
|
62
71
|
return Uint8Array.from(atob(t + "=".repeat((4 - t.length % 4) % 4)), (e) => e.charCodeAt(0));
|
|
63
72
|
}
|
|
64
|
-
function
|
|
73
|
+
function w(e, t) {
|
|
65
74
|
let n = e.options.applicationServerKey;
|
|
66
75
|
if (!n) return !1;
|
|
67
76
|
let r = new Uint8Array(n);
|
|
68
77
|
return r.length === t.length && r.every((e, n) => e === t[n]);
|
|
69
78
|
}
|
|
70
|
-
function
|
|
71
|
-
let e =
|
|
72
|
-
return
|
|
79
|
+
function T() {
|
|
80
|
+
let e = u("notifications.push");
|
|
81
|
+
return o(() => ({
|
|
73
82
|
title: e.raw("title"),
|
|
74
83
|
decision_requested: e.raw("decision_requested"),
|
|
75
84
|
assigned: e.raw("assigned"),
|
|
@@ -83,64 +92,64 @@ function C() {
|
|
|
83
92
|
fallback: e.raw("fallback")
|
|
84
93
|
}), [e]);
|
|
85
94
|
}
|
|
86
|
-
async function
|
|
87
|
-
await navigator.serviceWorker.register(`${e}/sw.js`, { scope:
|
|
95
|
+
async function E(r, i) {
|
|
96
|
+
await navigator.serviceWorker.register(`${e}/sw.js`, { scope: y() });
|
|
88
97
|
let a = await navigator.serviceWorker.ready;
|
|
89
98
|
a.active?.postMessage({
|
|
90
99
|
type: "messages",
|
|
91
100
|
messages: i
|
|
92
101
|
});
|
|
93
|
-
let o =
|
|
94
|
-
s && !
|
|
102
|
+
let o = C(r), s = await a.pushManager.getSubscription();
|
|
103
|
+
s && !w(s, o) && (await s.unsubscribe(), s = null), s ??= await a.pushManager.subscribe({
|
|
95
104
|
userVisibleOnly: !0,
|
|
96
105
|
applicationServerKey: o
|
|
97
106
|
}), n(await t.POST("/api/v1/push/subscriptions", { body: { endpoint: s.endpoint } }));
|
|
98
107
|
}
|
|
99
|
-
function
|
|
100
|
-
let { data: e } =
|
|
101
|
-
if (!
|
|
108
|
+
function D() {
|
|
109
|
+
let { data: e } = f(i), n = T(), [r, a] = l("off"), [c, u] = l(!1), d = o(async () => {
|
|
110
|
+
if (!S()) return a("unsupported");
|
|
102
111
|
if (!e) return;
|
|
103
|
-
if (!e.enabled) return
|
|
104
|
-
if (Notification.permission === "denied") return
|
|
105
|
-
let t = await (await
|
|
106
|
-
|
|
112
|
+
if (!e.enabled) return a("unavailable");
|
|
113
|
+
if (Notification.permission === "denied") return a("denied");
|
|
114
|
+
let t = await (await b())?.pushManager.getSubscription();
|
|
115
|
+
a(t && Notification.permission === "granted" ? "on" : "off");
|
|
107
116
|
}, [e]);
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
}, [
|
|
117
|
+
return s(() => {
|
|
118
|
+
d();
|
|
119
|
+
}, [d]), {
|
|
111
120
|
state: r,
|
|
112
|
-
pending:
|
|
113
|
-
enable:
|
|
121
|
+
pending: c,
|
|
122
|
+
enable: o(async () => {
|
|
114
123
|
if (e?.publicKey) {
|
|
115
124
|
u(!0);
|
|
116
125
|
try {
|
|
117
|
-
await Notification.requestPermission() === "granted" && await
|
|
126
|
+
await Notification.requestPermission() === "granted" && await E(e.publicKey, n());
|
|
118
127
|
} finally {
|
|
119
|
-
u(!1), await
|
|
128
|
+
u(!1), await d();
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
}, [
|
|
123
132
|
e,
|
|
124
133
|
n,
|
|
125
|
-
|
|
134
|
+
d
|
|
126
135
|
]),
|
|
127
|
-
disable:
|
|
136
|
+
disable: o(async () => {
|
|
128
137
|
u(!0);
|
|
129
138
|
try {
|
|
130
|
-
let e = await (await
|
|
139
|
+
let e = await (await b())?.pushManager.getSubscription();
|
|
131
140
|
e && (await t.DELETE("/api/v1/push/subscriptions", { params: { query: { endpoint: e.endpoint } } }), await e.unsubscribe());
|
|
132
141
|
} finally {
|
|
133
|
-
u(!1), await
|
|
142
|
+
u(!1), await d();
|
|
134
143
|
}
|
|
135
|
-
}, [
|
|
144
|
+
}, [d])
|
|
136
145
|
};
|
|
137
146
|
}
|
|
138
|
-
function
|
|
139
|
-
let { data: e } =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
n && await n.pushManager.getSubscription() && await
|
|
147
|
+
function O() {
|
|
148
|
+
let { data: e } = f(i), t = T();
|
|
149
|
+
s(() => {
|
|
150
|
+
S() && e?.enabled && e.publicKey && Notification.permission === "granted" && b().then(async (n) => {
|
|
151
|
+
n && await n.pushManager.getSubscription() && await E(e.publicKey, t());
|
|
143
152
|
}).catch(() => {});
|
|
144
153
|
}, [e, t]);
|
|
145
154
|
}
|
|
146
|
-
export {
|
|
155
|
+
export { _ as useArchiveNotifications, D as usePush, O as usePushSync, v as useReadIssueNotifications, h as useReadNotifications, g as useUnreadNotifications };
|
package/lib/shortcuts.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { shortcutName as e } from "./shortcutName.js";
|
|
2
|
+
import { isTextEntryContext as t } from "@parallelworks/ui";
|
|
3
|
+
import { useEffect as n, useRef as r } from "react";
|
|
2
4
|
// src/lib/shortcuts.ts
|
|
3
|
-
function
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function r(r, i = !0) {
|
|
12
|
-
let a = t(r);
|
|
13
|
-
a.current = r, e(() => {
|
|
14
|
-
if (!i) return;
|
|
15
|
-
let e = (e) => {
|
|
16
|
-
if (e.metaKey || e.ctrlKey || e.altKey || n(e.target)) return;
|
|
17
|
-
let t = a.current[e.key];
|
|
18
|
-
t && (e.preventDefault(), t(e));
|
|
5
|
+
function i(i, a = !0) {
|
|
6
|
+
let o = r(i);
|
|
7
|
+
o.current = i, n(() => {
|
|
8
|
+
if (!a) return;
|
|
9
|
+
let n = (n) => {
|
|
10
|
+
if (n.altKey || n.defaultPrevented || t(n.target)) return;
|
|
11
|
+
let r = o.current[e(n)];
|
|
12
|
+
r && (n.preventDefault(), r(n));
|
|
19
13
|
};
|
|
20
|
-
return window.addEventListener("keydown",
|
|
21
|
-
}, [
|
|
14
|
+
return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
|
|
15
|
+
}, [a]);
|
|
22
16
|
}
|
|
23
|
-
export {
|
|
17
|
+
export { i as useShortcuts };
|