Skip to content

Commit

Permalink
仮コミット
Browse files Browse the repository at this point in the history
  • Loading branch information
Aoichaan0513 committed Sep 14, 2022
1 parent 9c27650 commit 6f6748f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/user/normal/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ipcMain } from 'electron';
import { copyFile, mkdir } from 'fs/promises';
import { copyFile, mkdir, rm } from 'fs/promises';
import { extname } from 'path';
import { IPCChannel } from '../../../constants/ipc';
import { UserConfig, UserProfile, UserType } from '../../../interfaces/user';
Expand Down Expand Up @@ -100,6 +100,7 @@ export class NormalUser implements IUser {
ipcMain.handle(IPCChannel.User.SET_PROFILE(this.id), async (e, { name, avatar }: UserProfile) => {
this._settings.config = { profile: { name } };

const oldPath = this._settings.config.profile.avatar;
if (avatar) {
const targetName = `Avatar${extname(avatar)}`;
const targetPath = getUserDataPath(this.id, targetName);
Expand All @@ -117,6 +118,9 @@ export class NormalUser implements IUser {
this._settings.config = { profile: { avatar: null } };
}

if (oldPath)
await rm(oldPath);

const windows = Main.windowManager.getWindows(this);
windows.forEach((window) => {
window.viewManager.views.forEach((view) => view.setBounds());
Expand Down

0 comments on commit 6f6748f

Please sign in to comment.