From ab895a7d02c1617aa439c86d8b838becbd839b0f Mon Sep 17 00:00:00 2001 From: shu Date: Tue, 21 May 2019 16:13:13 +0200 Subject: [PATCH] Abandon --- src/App.vue | 174 +++--------------- src/components/ServiceEmiter.ts | 30 +-- src/components/ServiceHeader.vue | 11 +- src/components/service/AccountService.ts | 4 +- src/components/service/ConnectedService.ts | 2 +- src/helpers/loadable/AxiosLoadable.ts | 2 +- src/helpers/loadable/ErrorLoadable.ts | 1 + src/helpers/loadable/PromiseLoadable.ts | 19 ++ src/helpers/storage/LocalStorageHandler.ts | 7 - src/helpers/storage/StorageHandler.ts | 31 ++++ src/helpers/storage/WebStorageHandler.ts | 33 ---- .../{unsafeAxiosMapper.ts => unsafeMapper.ts} | 3 + src/services/discord/Client.vue | 2 +- src/services/mastodon/Client.vue | 8 +- src/services/nextcloud/NextcloudNews.vue | 4 +- .../openweathermap/OpenWeatherMap.vue | 12 +- src/store/App.ts | 25 +++ src/store/Errors.ts | 21 +++ src/store/Layouts.ts | 113 ++++++++++++ src/store/Services.ts | 67 +++++++ src/store/Time.ts | 4 +- src/store/index.ts | 18 ++ src/types/App.ts | 5 +- src/types/Events.ts | 49 ----- vue.config.js | 6 +- 25 files changed, 371 insertions(+), 280 deletions(-) create mode 100644 src/helpers/loadable/PromiseLoadable.ts delete mode 100644 src/helpers/storage/LocalStorageHandler.ts create mode 100644 src/helpers/storage/StorageHandler.ts delete mode 100644 src/helpers/storage/WebStorageHandler.ts rename src/helpers/{unsafeAxiosMapper.ts => unsafeMapper.ts} (63%) create mode 100644 src/store/App.ts create mode 100644 src/store/Errors.ts create mode 100644 src/store/Layouts.ts create mode 100644 src/store/Services.ts delete mode 100644 src/types/Events.ts diff --git a/src/App.vue b/src/App.vue index 310f4e8..4c43837 100644 --- a/src/App.vue +++ b/src/App.vue @@ -31,75 +31,35 @@ diff --git a/src/components/ServiceEmiter.ts b/src/components/ServiceEmiter.ts index ed78a0e..0c3981b 100644 --- a/src/components/ServiceEmiter.ts +++ b/src/components/ServiceEmiter.ts @@ -5,37 +5,37 @@ import LoadableBlock from './loadable/LoadableBlock.vue' import LoadableInline from './loadable/LoadableInline.vue' import SuccessLoadable from './loadable/SuccessLoadableBlock.vue' -import { ServiceData } from '@/types/App' -import * as Events from '@/types/Events' +import { ErrorsModule, LayoutsModule, ServicesModule } from '@/store' +import { Options, ServiceData } from '@/types/App' @Component({ components: { LoadableBlock, LoadableInline, SuccessLoadable } }) export default class ServiceEmiter extends Vue { - @Prop(Function) - readonly emit!: (name: string, msg: any) => void + @Prop(Number) + readonly tileKey!: number - emitError(err: string) { - this.emit(Events.ErrorEvent, err) + addError(error: any) { + ErrorsModule.add(error.toString()) } - saveOptions(options: object) { - this.emit(Events.SaveOptionsEvent, options) + saveOptions(options: Options) { + LayoutsModule.setTileOptions(this.tileKey, options) } saveOption(key: string, value: any) { - this.saveOptionCouple({ key, value }) + LayoutsModule.setTileOption(this.tileKey, key, value) } - saveOptionCouple(couple: Events.Option) { - this.emit(Events.SaveOptionEvent, couple) + saveOptionCouple({ key, value }: { key: string, value: any }) { + this.saveOption(key, value) } - saveService(service: ServiceData) { - this.emit(Events.SaveServiceEvent, service) + saveService({ name, auth }: ServiceData) { + ServicesModule.set(LayoutsModule.getTile(this.tileKey).service, name, auth) } - catchEmit(req: AxiosPromise) { + catchError(req: AxiosPromise) { return req.catch(err => { - this.emitError(err) + this.addError(err) throw err }) } diff --git a/src/components/ServiceHeader.vue b/src/components/ServiceHeader.vue index c29cfc9..1d90c26 100644 --- a/src/components/ServiceHeader.vue +++ b/src/components/ServiceHeader.vue @@ -16,24 +16,25 @@