fix: Trim trailing slash in Universal Inbox URL
This commit is contained in:
@@ -41,7 +41,7 @@ export function CreateTaskFromNotification({ notification, mutate }: CreateTaskF
|
|||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
const { isLoading, data: projects } = useFetch<Array<ProjectSummary>>(
|
const { isLoading, data: projects } = useFetch<Array<ProjectSummary>>(
|
||||||
`${preferences.universalInboxBaseUrl}/api/tasks/projects/search?matches=${searchText}`,
|
`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/tasks/projects/search?matches=${searchText}`,
|
||||||
{
|
{
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -123,7 +123,7 @@ async function createTaskFromNotification(
|
|||||||
try {
|
try {
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/notifications/${notification.id}/task`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/notifications/${notification.id}/task`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(taskCreation),
|
body: JSON.stringify(taskCreation),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function LinkNotificationToTask({ notification, mutate }: LinkNotificatio
|
|||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
const { isLoading, data: tasks } = useFetch<Array<Task>>(
|
const { isLoading, data: tasks } = useFetch<Array<Task>>(
|
||||||
`${preferences.universalInboxBaseUrl}/api/tasks/search?matches=${searchText}`,
|
`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/tasks/search?matches=${searchText}`,
|
||||||
{
|
{
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -78,7 +78,7 @@ async function linkNotificationToTask(
|
|||||||
try {
|
try {
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/notifications/${notification.id}`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/notifications/${notification.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({ status: TaskStatus.Deleted, task_id: taskId }),
|
body: JSON.stringify({ status: TaskStatus.Deleted, task_id: taskId }),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export async function deleteNotification(
|
|||||||
if (isNotificationBuiltFromTask(notification) && notification.task) {
|
if (isNotificationBuiltFromTask(notification) && notification.task) {
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/tasks/${notification.task.id}`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/tasks/${notification.task.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({ status: TaskStatus.Deleted }),
|
body: JSON.stringify({ status: TaskStatus.Deleted }),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -93,7 +93,7 @@ export async function deleteNotification(
|
|||||||
} else {
|
} else {
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/notifications/${notification.id}`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/notifications/${notification.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({ status: NotificationStatus.Deleted }),
|
body: JSON.stringify({ status: NotificationStatus.Deleted }),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -132,7 +132,7 @@ export async function unsubscribeFromNotification(
|
|||||||
try {
|
try {
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/notifications/${notification.id}`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/notifications/${notification.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({ status: NotificationStatus.Unsubscribed }),
|
body: JSON.stringify({ status: NotificationStatus.Unsubscribed }),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -171,7 +171,7 @@ export async function snoozeNotification(
|
|||||||
const snoozeTime = computeSnoozedUntil(new Date(), 1, 6);
|
const snoozeTime = computeSnoozedUntil(new Date(), 1, 6);
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/notifications/${notification.id}`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/notifications/${notification.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({ snoozed_until: snoozeTime }),
|
body: JSON.stringify({ snoozed_until: snoozeTime }),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ async function completeTask(notification: Notification, mutate: MutatePromise<Pa
|
|||||||
try {
|
try {
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/tasks/${notification.task.id}`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/tasks/${notification.task.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({ status: TaskStatus.Done }),
|
body: JSON.stringify({ status: TaskStatus.Done }),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function PlanTask({ notification, mutate }: PlanTaskProps) {
|
|||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
const { isLoading, data: projects } = useFetch<Array<ProjectSummary>>(
|
const { isLoading, data: projects } = useFetch<Array<ProjectSummary>>(
|
||||||
`${preferences.universalInboxBaseUrl}/api/tasks/projects/search?matches=${searchText}`,
|
`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/tasks/projects/search?matches=${searchText}`,
|
||||||
{
|
{
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -122,7 +122,7 @@ async function planTask(
|
|||||||
try {
|
try {
|
||||||
await mutate(
|
await mutate(
|
||||||
handleErrors(
|
handleErrors(
|
||||||
fetch(`${preferences.universalInboxBaseUrl}/api/tasks/${notification.task.id}`, {
|
fetch(`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/tasks/${notification.task.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
project: taskPlanning.project.name,
|
project: taskPlanning.project.name,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function Command() {
|
|||||||
|
|
||||||
const [notificationKind, setNotificationKind] = useState("");
|
const [notificationKind, setNotificationKind] = useState("");
|
||||||
const { isLoading, data, mutate } = useFetch<Page<Notification>>(
|
const { isLoading, data, mutate } = useFetch<Page<Notification>>(
|
||||||
`${preferences.universalInboxBaseUrl}/api/notifications?status=Unread,Read&with_tasks=true${
|
`${preferences.universalInboxBaseUrl.replace(/\/$/, "")}/api/notifications?status=Unread,Read&with_tasks=true${
|
||||||
notificationKind ? "¬ification_kind=" + notificationKind : ""
|
notificationKind ? "¬ification_kind=" + notificationKind : ""
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user