mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-08-04 19:25:13 -04:00
fix avatar update
This commit is contained in:
@@ -72,7 +72,6 @@
|
||||
});
|
||||
} else {
|
||||
await $pocketbase.admins.authRefresh().catch(() => {
|
||||
$pocketbase.authStore.clear();
|
||||
goto('/login');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,23 +23,21 @@
|
||||
|
||||
function changeAvatar() {
|
||||
if ($isAdmin) {
|
||||
if (!$pocketbase.authStore.model?.id) return;
|
||||
$pocketbase.admins
|
||||
.authRefresh()
|
||||
.then((data) => {
|
||||
data.admin.avatar = newAvatar;
|
||||
$pocketbase.authStore.save(data.token, data.admin);
|
||||
.update($pocketbase.authStore.model.id, { avatar: newAvatar })
|
||||
.then(() => {
|
||||
toast.success('Avatar saved.');
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
});
|
||||
} else {
|
||||
if (!$pocketbase.authStore.model?.id) return;
|
||||
$pocketbase
|
||||
.collection('users')
|
||||
.authRefresh()
|
||||
.then((data) => {
|
||||
data.record.avatar = newAvatar;
|
||||
$pocketbase.authStore.save(data.token, data.record);
|
||||
.update($pocketbase.authStore.model.id, { avatar: newAvatar })
|
||||
.then(() => {
|
||||
toast.success('Avatar saved.');
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user