@rimori/client 2.3.0-next.1 → 2.3.0-next.2
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { RimoriClient } from '../plugin/RimoriClient';
|
|
2
3
|
export type TriggerAction = {
|
|
3
4
|
action_key: string;
|
|
4
5
|
} & Record<string, string | number | boolean>;
|
|
@@ -25,7 +26,8 @@ export interface Exercise {
|
|
|
25
26
|
}
|
|
26
27
|
export declare class ExerciseController {
|
|
27
28
|
private supabase;
|
|
28
|
-
|
|
29
|
+
private rimoriClient;
|
|
30
|
+
constructor(supabase: SupabaseClient, rimoriClient: RimoriClient);
|
|
29
31
|
/**
|
|
30
32
|
* Fetches weekly exercises from the weekly_exercises view.
|
|
31
33
|
* Shows exercises for the current week that haven't expired.
|
|
@@ -8,8 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
export class ExerciseController {
|
|
11
|
-
constructor(supabase) {
|
|
11
|
+
constructor(supabase, rimoriClient) {
|
|
12
12
|
this.supabase = supabase;
|
|
13
|
+
this.rimoriClient = rimoriClient;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Fetches weekly exercises from the weekly_exercises view.
|
|
@@ -46,6 +47,7 @@ export class ExerciseController {
|
|
|
46
47
|
const errorText = yield response.text();
|
|
47
48
|
throw new Error(`Failed to create exercise: ${errorText}`);
|
|
48
49
|
}
|
|
50
|
+
this.rimoriClient.event.emit('global.exercises.triggerChange');
|
|
49
51
|
return yield response.json();
|
|
50
52
|
});
|
|
51
53
|
}
|
|
@@ -68,6 +70,7 @@ export class ExerciseController {
|
|
|
68
70
|
const errorText = yield response.text();
|
|
69
71
|
throw new Error(`Failed to delete exercise: ${errorText}`);
|
|
70
72
|
}
|
|
73
|
+
this.rimoriClient.event.emit('global.exercises.triggerChange');
|
|
71
74
|
return yield response.json();
|
|
72
75
|
});
|
|
73
76
|
}
|
|
@@ -273,7 +273,7 @@ export class RimoriClient {
|
|
|
273
273
|
this.rimoriInfo = info;
|
|
274
274
|
this.superbase = supabase;
|
|
275
275
|
this.pluginController = controller;
|
|
276
|
-
this.exerciseController = new ExerciseController(supabase);
|
|
276
|
+
this.exerciseController = new ExerciseController(supabase, this);
|
|
277
277
|
this.accomplishmentHandler = new AccomplishmentController(info.pluginId);
|
|
278
278
|
this.settingsController = new SettingsController(supabase, info.pluginId, info.guild);
|
|
279
279
|
this.sharedContentController = new SharedContentController(supabase, this);
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { RimoriClient } from '../plugin/RimoriClient';
|
|
2
3
|
|
|
3
4
|
export type TriggerAction = { action_key: string } & Record<string, string | number | boolean>;
|
|
4
5
|
|
|
@@ -27,9 +28,11 @@ export interface Exercise {
|
|
|
27
28
|
|
|
28
29
|
export class ExerciseController {
|
|
29
30
|
private supabase: SupabaseClient;
|
|
31
|
+
private rimoriClient: RimoriClient;
|
|
30
32
|
|
|
31
|
-
constructor(supabase: SupabaseClient) {
|
|
33
|
+
constructor(supabase: SupabaseClient, rimoriClient: RimoriClient) {
|
|
32
34
|
this.supabase = supabase;
|
|
35
|
+
this.rimoriClient = rimoriClient;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
/**
|
|
@@ -68,6 +71,7 @@ export class ExerciseController {
|
|
|
68
71
|
const errorText = await response.text();
|
|
69
72
|
throw new Error(`Failed to create exercise: ${errorText}`);
|
|
70
73
|
}
|
|
74
|
+
this.rimoriClient.event.emit('global.exercises.triggerChange');
|
|
71
75
|
|
|
72
76
|
return await response.json();
|
|
73
77
|
}
|
|
@@ -95,6 +99,7 @@ export class ExerciseController {
|
|
|
95
99
|
const errorText = await response.text();
|
|
96
100
|
throw new Error(`Failed to delete exercise: ${errorText}`);
|
|
97
101
|
}
|
|
102
|
+
this.rimoriClient.event.emit('global.exercises.triggerChange');
|
|
98
103
|
|
|
99
104
|
return await response.json();
|
|
100
105
|
}
|
|
@@ -39,7 +39,7 @@ export class RimoriClient {
|
|
|
39
39
|
this.rimoriInfo = info;
|
|
40
40
|
this.superbase = supabase;
|
|
41
41
|
this.pluginController = controller;
|
|
42
|
-
this.exerciseController = new ExerciseController(supabase);
|
|
42
|
+
this.exerciseController = new ExerciseController(supabase, this);
|
|
43
43
|
this.accomplishmentHandler = new AccomplishmentController(info.pluginId);
|
|
44
44
|
this.settingsController = new SettingsController(supabase, info.pluginId, info.guild);
|
|
45
45
|
this.sharedContentController = new SharedContentController(supabase, this);
|