Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions api/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { dynamicRemoteAccessReducer } from '@app/store/modules/dynamic-remote-ac
import { dynamix } from '@app/store/modules/dynamix.js';
import { emhttp } from '@app/store/modules/emhttp.js';
import { mothership } from '@app/store/modules/minigraph.js';
import { notificationReducer } from '@app/store/modules/notifications.js';
import { paths } from '@app/store/modules/paths.js';
import { registration } from '@app/store/modules/registration.js';
import { remoteGraphQLReducer } from '@app/store/modules/remote-graphql.js';
Expand All @@ -23,7 +22,6 @@ export const store = configureStore({
emhttp: emhttp.reducer,
registration: registration.reducer,
remoteGraphQL: remoteGraphQLReducer,
notifications: notificationReducer,
cache: cache.reducer,
docker: docker.reducer,
upnp: upnp.reducer,
Expand All @@ -46,7 +44,6 @@ export const getters = {
dynamix: () => store.getState().dynamix,
emhttp: () => store.getState().emhttp,
minigraph: () => store.getState().minigraph,
notifications: () => store.getState().notifications,
paths: () => store.getState().paths,
registration: () => store.getState().registration,
remoteGraphQL: () => store.getState().remoteGraphQL,
Expand Down
21 changes: 0 additions & 21 deletions api/src/store/listeners/notification-path-listener.ts

This file was deleted.

92 changes: 0 additions & 92 deletions api/src/store/modules/notifications.ts

This file was deleted.

4 changes: 0 additions & 4 deletions api/src/store/store-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ export const startStoreSync = async () => {
join(state.paths.states, 'graphql.log'),
JSON.stringify(state.minigraph, null, 2)
);
writeFileSync(
join(state.paths.states, 'notifications.log'),
JSON.stringify(state.notifications, null, 2)
);
}

lastState = state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import { batchProcess, formatDatetime, isFulfilled, isRejected, unraidTimestamp
export class NotificationsService {
private logger = new Logger(NotificationsService.name);
private static watcher: FSWatcher | null = null;
/**
* The path to the notification directory - will be updated if the user changes the notifier path
*/
private path: string | null = null;

private static overview: NotificationOverview = {
unread: {
Expand All @@ -50,7 +54,8 @@ export class NotificationsService {
};

constructor() {
NotificationsService.watcher = this.getNotificationsWatcher();
this.path = getters.dynamix().notify!.path;
void this.getNotificationsWatcher(this.path);
}

/**
Expand All @@ -63,6 +68,13 @@ export class NotificationsService {
*/
public paths(): Record<'basePath' | NotificationType, string> {
const basePath = getters.dynamix().notify!.path;

if (this.path !== basePath) {
// Recreate the watcher with force = true
void this.getNotificationsWatcher(basePath, true);
this.path = basePath;
}

const makePath = (type: NotificationType) => join(basePath, type.toLowerCase());
return {
basePath,
Expand All @@ -78,12 +90,11 @@ export class NotificationsService {
* events to their event handlers.
*------------------------------------------------------------------------**/

private getNotificationsWatcher() {
const { basePath } = this.paths();

if (NotificationsService.watcher) {
private async getNotificationsWatcher(basePath: string, recreate = false): Promise<FSWatcher> {
if (NotificationsService.watcher && !recreate) {
return NotificationsService.watcher;
}
await NotificationsService.watcher?.close().catch((e) => this.logger.error(e));

NotificationsService.watcher = watch(basePath, { usePolling: CHOKIDAR_USEPOLLING }).on(
'add',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1739911366509
1740588065597
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1739911365729
1740588063495
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1739911366308
1740588063858
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1739911366763
1740588065854
Loading