summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-03-20 15:42:02 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-03-20 15:42:02 +0900
commit9bb6dc52b855dcebd0c0493240d6282ba21810c2 (patch)
treedc9bf37dc92ef48fb5ca47d4439b9f70bf0f2f38 /src
parentクライアントサイドで実装したいため一旦 injectPromo およ... (diff)
downloadsharkey-9bb6dc52b855dcebd0c0493240d6282ba21810c2.tar.gz
sharkey-9bb6dc52b855dcebd0c0493240d6282ba21810c2.tar.bz2
sharkey-9bb6dc52b855dcebd0c0493240d6282ba21810c2.zip
clean up など
Diffstat (limited to 'src')
-rw-r--r--src/client/init.ts34
-rw-r--r--src/client/store.ts1
-rw-r--r--src/client/theme-store.ts27
-rw-r--r--src/server/api/define.ts1
-rw-r--r--src/server/api/endpoints/i.ts27
5 files changed, 4 insertions, 86 deletions
diff --git a/src/client/init.ts b/src/client/init.ts
index 1c44e7f23e..2a2b6a2f86 100644
--- a/src/client/init.ts
+++ b/src/client/init.ts
@@ -4,40 +4,6 @@
import '@/style.scss';
-// TODO: そのうち消す
-if (localStorage.getItem('vuex') != null) {
- const vuex = JSON.parse(localStorage.getItem('vuex'));
-
- localStorage.setItem('account', JSON.stringify({
- ...vuex.i,
- token: localStorage.getItem('i')
- }));
- localStorage.setItem('accounts', JSON.stringify(vuex.device.accounts));
- localStorage.setItem('miux:themes', JSON.stringify(vuex.device.themes));
-
- if (vuex.device.userData) {
- for (const [k, v] of Object.entries(vuex.device.userData)) {
- localStorage.setItem('pizzax::base::' + k, JSON.stringify({
- widgets: v.widgets
- }));
-
- if (v.deck) {
- localStorage.setItem('pizzax::deck::' + k, JSON.stringify({
- columns: v.deck.columns,
- layout: v.deck.layout,
- }));
- }
- }
- }
-
- localStorage.setItem('vuex-old', JSON.stringify(vuex));
- localStorage.removeItem('vuex');
- localStorage.removeItem('i');
- localStorage.removeItem('locale');
-
- location.reload();
-}
-
import * as Sentry from '@sentry/browser';
import { Integrations } from '@sentry/tracing';
import { createApp, watch } from 'vue';
diff --git a/src/client/store.ts b/src/client/store.ts
index 14924dadd0..e6fdd12f1d 100644
--- a/src/client/store.ts
+++ b/src/client/store.ts
@@ -212,7 +212,6 @@ type Plugin = {
*/
export class ColdDeviceStorage {
public static default = {
- themes: [] as Theme[], // TODO: そのうち消す
// TODO: テーマをアカウントに保存するようになったのにもかかわらず、以下のどのテーマを使うかという情報だけがブラウザ保存になっていて、アカウント切り替えたりログアウトしたときに不具合が発生するのでなんとかする
// テーマIDを保存するのではなく、テーマ自体を保存するようにすれば解決するかも
darkTheme: '8050783a-7f63-445a-b270-36d0f6ba1677',
diff --git a/src/client/theme-store.ts b/src/client/theme-store.ts
index 5e440efbf9..8e21af70fc 100644
--- a/src/client/theme-store.ts
+++ b/src/client/theme-store.ts
@@ -33,30 +33,3 @@ export async function removeTheme(theme: Theme): Promise<void> {
await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes });
localStorage.setItem(lsCacheKey, JSON.stringify(themes));
}
-
-// TODO: そのうち消す
-if (ColdDeviceStorage.get('themes').length > 0) {
- const lsThemes = ColdDeviceStorage.get('themes');
- let registryThemes;
- try {
- registryThemes = await api('i/registry/get', { scope: ['client'], key: 'themes' });
- } catch (e) {
- if (e.code === 'NO_SUCH_KEY') {
- registryThemes = [];
- } else {
- throw e;
- }
- }
- const themes = [] as Theme[];
- for (const theme of lsThemes) {
- if (themes.some(x => x.id === theme.id)) continue;
- themes.push(theme);
- }
- for (const theme of registryThemes) {
- if (themes.some(x => x.id === theme.id)) continue;
- themes.push(theme);
- }
- await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes });
- localStorage.setItem(lsCacheKey, JSON.stringify(themes));
- ColdDeviceStorage.set('themes', []);
-}
diff --git a/src/server/api/define.ts b/src/server/api/define.ts
index 1c7ee26479..4e59357c13 100644
--- a/src/server/api/define.ts
+++ b/src/server/api/define.ts
@@ -18,6 +18,7 @@ type executor<T extends IEndpointMeta> =
(params: Params<T>, user: T['requireCredential'] extends true ? ILocalUser : ILocalUser | null, token: AccessToken | null, file?: any, cleanup?: Function) =>
Promise<T['res'] extends undefined ? Response : SchemaType<NonNullable<T['res']>>>;
+// TODO: API関数に user まるごと渡すのではなくユーザーIDなどの最小限のプロパティだけ渡すようにしたい(キャッシュとか考えないでよくなるため)
export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>)
: (params: any, user: T['requireCredential'] extends true ? ILocalUser : ILocalUser | null, token: AccessToken | null, file?: any) => Promise<any> {
return (params: any, user: T['requireCredential'] extends true ? ILocalUser : ILocalUser | null, token: AccessToken | null, file?: any) => {
diff --git a/src/server/api/endpoints/i.ts b/src/server/api/endpoints/i.ts
index e5b65e0930..87f6ae778d 100644
--- a/src/server/api/endpoints/i.ts
+++ b/src/server/api/endpoints/i.ts
@@ -1,6 +1,5 @@
import define from '../define';
-import { RegistryItems, UserProfiles, Users } from '../../../models';
-import { genId } from '../../../misc/gen-id';
+import { Users } from '../../../models';
export const meta = {
desc: {
@@ -23,28 +22,8 @@ export const meta = {
export default define(meta, async (ps, user, token) => {
const isSecure = token == null;
- // TODO: そのうち消す
- const profile = await UserProfiles.findOneOrFail(user.id);
- for (const [k, v] of Object.entries(profile.clientData)) {
- await RegistryItems.insert({
- id: genId(),
- createdAt: new Date(),
- updatedAt: new Date(),
- userId: user.id,
- domain: null,
- scope: ['client', 'base'],
- key: k,
- value: v
- });
- }
- await UserProfiles.createQueryBuilder().update()
- .set({
- clientData: {},
- })
- .where('userId = :id', { id: user.id })
- .execute();
-
- return await Users.pack(user, user, {
+ // ここで渡ってきている user はキャッシュされていて古い可能性もあるので id だけ渡す
+ return await Users.pack(user.id, user, {
detail: true,
includeSecrets: isSecure
});