version 0.3.0 #1

Merged
ari merged 22 commits from dev into main 2024-07-02 19:39:03 +00:00
4 changed files with 10 additions and 14 deletions
Showing only changes of commit 6c11c67eb4 - Show all commits

View file

@ -313,15 +313,5 @@ export async function getUser(user_id) {
headers: { "Authorization": "Bearer " + get(client).app.token }
}).then(res => res.json());
const user = await parseUser(data);
if (user === null || user === undefined) {
if (data.id) {
console.warn("Failed to parse user data #" + data.id);
} else {
console.warn("Failed to parse user data:");
console.warn(data);
}
return false;
}
return user;
return data;
}

View file

@ -74,7 +74,7 @@ export class Client {
return await api.revokeToken();
}
async getUser() {
async getClientUser() {
// already known
if (this.user) return this.user;
@ -90,6 +90,7 @@ export class Client {
}
const user = await api.parseUser(data);
console.log(`Logged in as @${user.username}@${user.host}`);
console.log(`You have ${data.source.follow_request_count} follow request${data.source.follow_request_count === 1 ? '' : 's'}!`);
return user;
}
@ -161,6 +162,10 @@ export class Client {
return emoji;
}
async getUser(user_id) {
return await api.getUser(user_id);
}
save() {
if (typeof localStorage === typeof undefined) return;
localStorage.setItem(save_name, JSON.stringify({

View file

@ -12,13 +12,14 @@
let new_client = new Client();
new_client.load();
return new_client.getUser().then(user => {
return new_client.getClientUser().then(user => {
if (!user) {
client.set(new_client);
return resolve();
}
new_client.user = user;
client.set(new_client);
client.user
return resolve();
});
});

View file

@ -23,7 +23,7 @@
return c;
});
get(client).getUser().then(user => {
get(client).getClientUser().then(user => {
if (user) client.update(client => {
client.user = user
return client;