parent
946c3a25b9
commit
85959a3b9b
4 changed files with 26 additions and 23 deletions
|
@ -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;
|
||||
|
|
|
@ -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 })`
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ const defaultSettings = {
|
|||
iLikeSushi: false,
|
||||
rememberNoteVisibility: false,
|
||||
defaultNoteVisibility: 'public',
|
||||
wallpaper: null,
|
||||
webSearchEngine: 'https://www.google.com/?#q={{query}}',
|
||||
mutedWords: [],
|
||||
games: {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue