diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-04-17 14:30:31 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-04-17 14:30:31 +0900 |
| commit | 85959a3b9bef93e9b26e6b58c49145d6f67ea571 (patch) | |
| tree | 783e7bde3e66444913884e97fcf8c0d81599974d /src | |
| parent | Clean up (diff) | |
| download | misskey-85959a3b9bef93e9b26e6b58c49145d6f67ea571.tar.gz misskey-85959a3b9bef93e9b26e6b58c49145d6f67ea571.tar.bz2 misskey-85959a3b9bef93e9b26e6b58c49145d6f67ea571.zip | |
Fix #4721 Fix #4722
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/common/views/components/settings/settings.vue | 8 | ||||
| -rw-r--r-- | src/client/app/desktop/views/components/ui.vue | 7 | ||||
| -rw-r--r-- | src/client/app/store.ts | 1 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/update.ts | 33 |
4 files changed, 26 insertions, 23 deletions
diff --git a/src/client/app/common/views/components/settings/settings.vue b/src/client/app/common/views/components/settings/settings.vue index 001b692551..be2d7fce85 100644 --- a/src/client/app/common/views/components/settings/settings.vue +++ b/src/client/app/common/views/components/settings/settings.vue @@ -525,15 +525,11 @@ export default Vue.extend({ this.$chooseDriveFile({ multiple: false }).then(file => { - this.$root.api('i/update', { - wallpaperId: file.id - }); + this.$store.dispatch('settings/set', { key: 'wallpaper', value: file.url }); }); }, deleteWallpaper() { - this.$root.api('i/update', { - wallpaperId: null - }); + this.$store.dispatch('settings/set', { key: 'wallpaper', value: null }); }, checkForUpdate() { this.checkingForUpdate = true; diff --git a/src/client/app/desktop/views/components/ui.vue b/src/client/app/desktop/views/components/ui.vue index fa5efbc93e..d29fbdc1a5 100644 --- a/src/client/app/desktop/views/components/ui.vue +++ b/src/client/app/desktop/views/components/ui.vue @@ -1,6 +1,6 @@ <template> <div class="mk-ui" v-hotkey.global="keymap"> - <div class="bg" v-if="$store.getters.isSignedIn && $store.state.i.wallpaperUrl" :style="style"></div> + <div class="bg" v-if="$store.getters.isSignedIn && $store.state.settings.wallpaper" :style="style"></div> <x-header class="header" v-if="navbar == 'top'" v-show="!zenMode" ref="header"/> <x-sidebar class="sidebar" v-if="navbar != 'top'" v-show="!zenMode" ref="sidebar"/> <div class="content" :class="[{ sidebar: navbar != 'top', zen: zenMode }, navbar]"> @@ -33,10 +33,9 @@ export default Vue.extend({ }, style(): any { - if (!this.$store.getters.isSignedIn || this.$store.state.i.wallpaperUrl == null) return {}; + if (!this.$store.getters.isSignedIn || this.$store.state.settings.wallpaper == null) return {}; return { - backgroundColor: this.$store.state.i.wallpaperColor && this.$store.state.i.wallpaperColor.length == 3 ? `rgb(${ this.$store.state.i.wallpaperColor.join(',') })` : null, - backgroundImage: `url(${ this.$store.state.i.wallpaperUrl })` + backgroundImage: `url(${ this.$store.state.settings.wallpaper })` }; }, diff --git a/src/client/app/store.ts b/src/client/app/store.ts index c82981ad24..44b893835c 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -28,6 +28,7 @@ const defaultSettings = { iLikeSushi: false, rememberNoteVisibility: false, defaultNoteVisibility: 'public', + wallpaper: null, webSearchEngine: 'https://www.google.com/?#q={{query}}', mutedWords: [], games: { diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index d06ab621c6..8649b59c00 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -13,6 +13,7 @@ import { ApiError } from '../../error'; import { Users, DriveFiles, UserProfiles } from '../../../../models'; import { User } from '../../../../models/entities/user'; import { UserProfile } from '../../../../models/entities/user-profile'; +import { ensure } from '../../../../prelude/ensure'; export const meta = { desc: { @@ -157,22 +158,24 @@ export default define(meta, async (ps, user, app) => { const isSecure = user != null && app == null; const updates = {} as Partial<User>; - const profile = {} as Partial<UserProfile>; + const profileUpdates = {} as Partial<UserProfile>; + + const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure); if (ps.name !== undefined) updates.name = ps.name; - if (ps.description !== undefined) profile.description = ps.description; + if (ps.description !== undefined) profileUpdates.description = ps.description; //if (ps.lang !== undefined) updates.lang = ps.lang; - if (ps.location !== undefined) profile.location = ps.location; - if (ps.birthday !== undefined) profile.birthday = ps.birthday; + if (ps.location !== undefined) profileUpdates.location = ps.location; + if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday; if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId; if (ps.bannerId !== undefined) updates.bannerId = ps.bannerId; if (typeof ps.isLocked == 'boolean') updates.isLocked = ps.isLocked; if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot; - if (typeof ps.carefulBot == 'boolean') profile.carefulBot = ps.carefulBot; - if (typeof ps.autoAcceptFollowed == 'boolean') profile.autoAcceptFollowed = ps.autoAcceptFollowed; + if (typeof ps.carefulBot == 'boolean') profileUpdates.carefulBot = ps.carefulBot; + if (typeof ps.autoAcceptFollowed == 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed; if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat; - if (typeof ps.autoWatch == 'boolean') profile.autoWatch = ps.autoWatch; - if (typeof ps.alwaysMarkNsfw == 'boolean') profile.alwaysMarkNsfw = ps.alwaysMarkNsfw; + if (typeof ps.autoWatch == 'boolean') profileUpdates.autoWatch = ps.autoWatch; + if (typeof ps.alwaysMarkNsfw == 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw; if (ps.avatarId) { const avatar = await DriveFiles.findOne(ps.avatarId); @@ -201,16 +204,20 @@ export default define(meta, async (ps, user, app) => { } //#region emojis/tags + let emojis = [] as string[]; let tags = [] as string[]; - if (updates.name != null) { - const tokens = parsePlain(updates.name); + const newName = updates.name === undefined ? user.name : updates.name; + const newDescription = profileUpdates.description === undefined ? profile.description : profileUpdates.description; + + if (newName != null) { + const tokens = parsePlain(newName); emojis = emojis.concat(extractEmojis(tokens!)); } - if (profile.description != null) { - const tokens = parse(profile.description); + if (newDescription != null) { + const tokens = parse(newDescription); emojis = emojis.concat(extractEmojis(tokens!)); tags = extractHashtags(tokens!).map(tag => tag.toLowerCase()); } @@ -224,7 +231,7 @@ export default define(meta, async (ps, user, app) => { //#endregion if (Object.keys(updates).length > 0) await Users.update(user.id, updates); - if (Object.keys(profile).length > 0) await UserProfiles.update({ userId: user.id }, profile); + if (Object.keys(profileUpdates).length > 0) await UserProfiles.update({ userId: user.id }, profileUpdates); const iObj = await Users.pack(user.id, user, { detail: true, |