@fluid-topics/ft-app-context 1.0.22 → 1.0.24

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.
@@ -0,0 +1,20 @@
1
+ import { FtMySearch } from "@fluid-topics/public-api";
2
+ import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
3
+ import { PayloadAction } from "@reduxjs/toolkit";
4
+ export declare const FtUserAssetsStoreName = "ft-user-assets";
5
+ export interface FtUserAssetsState {
6
+ savedSearches?: Array<FtMySearch>;
7
+ }
8
+ declare const reducers: {
9
+ setSavedSearches: (state: FtUserAssetsState, action: PayloadAction<FtUserAssetsState["savedSearches"]>) => void;
10
+ };
11
+ export type FtUserAssetsStateReducers = typeof reducers;
12
+ export type FtUserAssetsStore = FtReduxStore<FtUserAssetsState, FtUserAssetsStateReducers>;
13
+ export declare const ftUserAssetsStore: FtUserAssetsStore;
14
+ declare class UserAssetsActions {
15
+ clear(): void;
16
+ clearMySearches(): void;
17
+ reloadMySearches(): Promise<void>;
18
+ }
19
+ export declare const userAssetsActions: UserAssetsActions;
20
+ export {};
@@ -0,0 +1,29 @@
1
+ import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
2
+ import { SavedSearchesService } from "../services/SavedSearchesService";
3
+ export const FtUserAssetsStoreName = "ft-user-assets";
4
+ const reducers = {
5
+ setSavedSearches: (state, action) => {
6
+ state.savedSearches = action.payload;
7
+ },
8
+ };
9
+ export const ftUserAssetsStore = FtReduxStore.get({
10
+ name: FtUserAssetsStoreName,
11
+ reducers: reducers,
12
+ initialState: {
13
+ savedSearches: undefined
14
+ }
15
+ });
16
+ class UserAssetsActions {
17
+ clear() {
18
+ this.clearMySearches();
19
+ }
20
+ clearMySearches() {
21
+ ftUserAssetsStore.actions.setSavedSearches(undefined);
22
+ }
23
+ async reloadMySearches() {
24
+ const savedSearchesService = new SavedSearchesService();
25
+ const mySearches = await savedSearchesService.listMySearches();
26
+ ftUserAssetsStore.actions.setSavedSearches(mySearches);
27
+ }
28
+ }
29
+ export const userAssetsActions = new UserAssetsActions();
@@ -0,0 +1,4 @@
1
+ import { FtMySearch } from "@fluid-topics/public-api";
2
+ export declare class SavedSearchesService {
3
+ listMySearches(): Promise<FtMySearch[]>;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { FluidTopicsApiProvider } from "./FluidTopicsApiProvider";
2
+ import { ftAppInfoStore } from "../redux-stores/FtAppInfoStore";
3
+ export class SavedSearchesService {
4
+ async listMySearches() {
5
+ var _a;
6
+ if (!((_a = ftAppInfoStore.getState().session) === null || _a === void 0 ? void 0 : _a.sessionAuthenticated)) {
7
+ return [];
8
+ }
9
+ return (await FluidTopicsApiProvider.await()).listMySearches(ftAppInfoStore.getState().session.profile.userId);
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-app-context",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Global application context for Fluid Topics integrations",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,14 +19,14 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "1.0.22",
22
+ "@fluid-topics/ft-wc-utils": "1.0.24",
23
23
  "lit": "2.7.2"
24
24
  },
25
25
  "devDependencies": {
26
- "@fluid-topics/public-api": "1.0.34"
26
+ "@fluid-topics/public-api": "1.0.37"
27
27
  },
28
28
  "peerDependencies": {
29
- "@fluid-topics/public-api": "1.0.34"
29
+ "@fluid-topics/public-api": "1.0.37"
30
30
  },
31
- "gitHead": "d68f9748c223f9e8eb8da2da4f410e02a2121d36"
31
+ "gitHead": "e8a11308219b004caea5b4d992dd36d6f5ca430b"
32
32
  }