mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 13:36:20 +00:00
Delegate tag color storage to ShlinkWebComponent consuming app
This commit is contained in:
15
src/utils/services/TagColorsStorage.ts
Normal file
15
src/utils/services/TagColorsStorage.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { TagColorsStorage as BaseTagColorsStorage } from '@shlinkio/shlink-web-component';
|
||||
import type { LocalStorage } from './LocalStorage';
|
||||
|
||||
export class TagColorsStorage implements BaseTagColorsStorage {
|
||||
constructor(private readonly storage: LocalStorage) {
|
||||
}
|
||||
|
||||
getTagColors(): Record<string, string> {
|
||||
return this.storage.get<Record<string, string>>('colors') ?? {};
|
||||
}
|
||||
|
||||
storeTagColors(colors: Record<string, string>): void {
|
||||
this.storage.set('colors', colors);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@ import type Bottle from 'bottlejs';
|
||||
import { csvToJson, jsonToCsv } from '../helpers/csvjson';
|
||||
import { useTimeoutToggle } from '../helpers/hooks';
|
||||
import { LocalStorage } from './LocalStorage';
|
||||
import { TagColorsStorage } from './TagColorsStorage';
|
||||
|
||||
export const provideServices = (bottle: Bottle) => {
|
||||
bottle.constant('localStorage', window.localStorage);
|
||||
bottle.service('Storage', LocalStorage, 'localStorage');
|
||||
bottle.service('TagColorsStorage', TagColorsStorage, 'Storage');
|
||||
|
||||
bottle.constant('csvToJson', csvToJson);
|
||||
bottle.constant('jsonToCsv', jsonToCsv);
|
||||
|
||||
Reference in New Issue
Block a user