parent
946c3a25b9
commit
85959a3b9b
4 changed files with 26 additions and 23 deletions
|
@ -525,15 +525,11 @@ export default Vue.extend({
|
||||||
this.$chooseDriveFile({
|
this.$chooseDriveFile({
|
||||||
multiple: false
|
multiple: false
|
||||||
}).then(file => {
|
}).then(file => {
|
||||||
this.$root.api('i/update', {
|
this.$store.dispatch('settings/set', { key: 'wallpaper', value: file.url });
|
||||||
wallpaperId: file.id
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteWallpaper() {
|
deleteWallpaper() {
|
||||||
this.$root.api('i/update', {
|
this.$store.dispatch('settings/set', { key: 'wallpaper', value: null });
|
||||||
wallpaperId: null
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
checkForUpdate() {
|
checkForUpdate() {
|
||||||
this.checkingForUpdate = true;
|
this.checkingForUpdate = true;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="mk-ui" v-hotkey.global="keymap">
|
<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-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"/>
|
<x-sidebar class="sidebar" v-if="navbar != 'top'" v-show="!zenMode" ref="sidebar"/>
|
||||||
<div class="content" :class="[{ sidebar: navbar != 'top', zen: zenMode }, navbar]">
|
<div class="content" :class="[{ sidebar: navbar != 'top', zen: zenMode }, navbar]">
|
||||||
|
@ -33,10 +33,9 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
style(): any {
|
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 {
|
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.settings.wallpaper })`
|
||||||
backgroundImage: `url(${ this.$store.state.i.wallpaperUrl })`
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ const defaultSettings = {
|
||||||
iLikeSushi: false,
|
iLikeSushi: false,
|
||||||
rememberNoteVisibility: false,
|
rememberNoteVisibility: false,
|
||||||
defaultNoteVisibility: 'public',
|
defaultNoteVisibility: 'public',
|
||||||
|
wallpaper: null,
|
||||||
webSearchEngine: 'https://www.google.com/?#q={{query}}',
|
webSearchEngine: 'https://www.google.com/?#q={{query}}',
|
||||||
mutedWords: [],
|
mutedWords: [],
|
||||||
games: {
|
games: {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { ApiError } from '../../error';
|
||||||
import { Users, DriveFiles, UserProfiles } from '../../../../models';
|
import { Users, DriveFiles, UserProfiles } from '../../../../models';
|
||||||
import { User } from '../../../../models/entities/user';
|
import { User } from '../../../../models/entities/user';
|
||||||
import { UserProfile } from '../../../../models/entities/user-profile';
|
import { UserProfile } from '../../../../models/entities/user-profile';
|
||||||
|
import { ensure } from '../../../../prelude/ensure';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -157,22 +158,24 @@ export default define(meta, async (ps, user, app) => {
|
||||||
const isSecure = user != null && app == null;
|
const isSecure = user != null && app == null;
|
||||||
|
|
||||||
const updates = {} as Partial<User>;
|
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.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.lang !== undefined) updates.lang = ps.lang;
|
||||||
if (ps.location !== undefined) profile.location = ps.location;
|
if (ps.location !== undefined) profileUpdates.location = ps.location;
|
||||||
if (ps.birthday !== undefined) profile.birthday = ps.birthday;
|
if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday;
|
||||||
if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId;
|
if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId;
|
||||||
if (ps.bannerId !== undefined) updates.bannerId = ps.bannerId;
|
if (ps.bannerId !== undefined) updates.bannerId = ps.bannerId;
|
||||||
if (typeof ps.isLocked == 'boolean') updates.isLocked = ps.isLocked;
|
if (typeof ps.isLocked == 'boolean') updates.isLocked = ps.isLocked;
|
||||||
if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot;
|
if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot;
|
||||||
if (typeof ps.carefulBot == 'boolean') profile.carefulBot = ps.carefulBot;
|
if (typeof ps.carefulBot == 'boolean') profileUpdates.carefulBot = ps.carefulBot;
|
||||||
if (typeof ps.autoAcceptFollowed == 'boolean') profile.autoAcceptFollowed = ps.autoAcceptFollowed;
|
if (typeof ps.autoAcceptFollowed == 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
|
||||||
if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat;
|
if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat;
|
||||||
if (typeof ps.autoWatch == 'boolean') profile.autoWatch = ps.autoWatch;
|
if (typeof ps.autoWatch == 'boolean') profileUpdates.autoWatch = ps.autoWatch;
|
||||||
if (typeof ps.alwaysMarkNsfw == 'boolean') profile.alwaysMarkNsfw = ps.alwaysMarkNsfw;
|
if (typeof ps.alwaysMarkNsfw == 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
|
||||||
|
|
||||||
if (ps.avatarId) {
|
if (ps.avatarId) {
|
||||||
const avatar = await DriveFiles.findOne(ps.avatarId);
|
const avatar = await DriveFiles.findOne(ps.avatarId);
|
||||||
|
@ -201,16 +204,20 @@ export default define(meta, async (ps, user, app) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
//#region emojis/tags
|
//#region emojis/tags
|
||||||
|
|
||||||
let emojis = [] as string[];
|
let emojis = [] as string[];
|
||||||
let tags = [] as string[];
|
let tags = [] as string[];
|
||||||
|
|
||||||
if (updates.name != null) {
|
const newName = updates.name === undefined ? user.name : updates.name;
|
||||||
const tokens = parsePlain(updates.name);
|
const newDescription = profileUpdates.description === undefined ? profile.description : profileUpdates.description;
|
||||||
|
|
||||||
|
if (newName != null) {
|
||||||
|
const tokens = parsePlain(newName);
|
||||||
emojis = emojis.concat(extractEmojis(tokens!));
|
emojis = emojis.concat(extractEmojis(tokens!));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.description != null) {
|
if (newDescription != null) {
|
||||||
const tokens = parse(profile.description);
|
const tokens = parse(newDescription);
|
||||||
emojis = emojis.concat(extractEmojis(tokens!));
|
emojis = emojis.concat(extractEmojis(tokens!));
|
||||||
tags = extractHashtags(tokens!).map(tag => tag.toLowerCase());
|
tags = extractHashtags(tokens!).map(tag => tag.toLowerCase());
|
||||||
}
|
}
|
||||||
|
@ -224,7 +231,7 @@ export default define(meta, async (ps, user, app) => {
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
if (Object.keys(updates).length > 0) await Users.update(user.id, updates);
|
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, {
|
const iObj = await Users.pack(user.id, user, {
|
||||||
detail: true,
|
detail: true,
|
||||||
|
|
Loading…
Reference in a new issue