MCPcopy Index your code
hub / github.com/coder/coder / updateNotificationTemplateMethod

Function updateNotificationTemplateMethod

site/src/api/queries/notifications.ts:114–146  ·  view source on GitHub ↗
(
	templateId: string,
	queryClient: QueryClient,
)

Source from the content-addressed store, hash-verified

112};
113
114export const updateNotificationTemplateMethod = (
115 templateId: string,
116 queryClient: QueryClient,
117) => {
118 return {
119 mutationFn: (req: UpdateNotificationTemplateMethod) =>
120 API.updateNotificationTemplateMethod(templateId, req),
121 onMutate: (data) => {
122 const keys = [
123 systemNotificationTemplatesKey,
124 customNotificationTemplatesKey,
125 ];
126
127 for (const key of keys) {
128 const prev = queryClient.getQueryData<NotificationTemplate[]>(key);
129 if (!prev) {
130 continue;
131 }
132
133 queryClient.setQueryData(
134 key,
135 prev.map((tpl) =>
136 tpl.id === templateId ? { ...tpl, method: data.method } : tpl,
137 ),
138 );
139 }
140 },
141 } satisfies UseMutationOptions<
142 void,
143 unknown,
144 UpdateNotificationTemplateMethod
145 >;
146};
147
148export const disableNotification = (
149 userId: string,

Callers 1

MethodToggleGroupFunction · 0.90

Tested by

no test coverage detected