Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

[Fix #31] Handle bad profile and try again #37

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ module.exports = class FritterApp {

async loadCurrentUserProfile () {
this.currentUserProfile = await this.libfritter.social.getProfile(this.currentUser)
if ( this.currentUserProfile !== undefined) {
this.currentUserProfile.isCurrentUser = true
}
}

async setView (view, param) {
Expand All @@ -143,8 +145,18 @@ module.exports = class FritterApp {
// use `runInnerLoad` to only apply the updates if setView() isn't called again while loading
await this.runInnerLoad(async (apply) => {
if (view === 'feed') {
apply({posts: await this.loadFeedPosts()})
document.title = 'Fritter'
if (this.currentUserProfile !== undefined) {
apply({ posts: await this.loadFeedPosts() });
document.title = "Fritter";
} else {
window.localStorage.removeItem("userUrl");
this.currentUser = null;
apply({
viewError: yo`<div>
${renderErrorIcon()} Selected profile is empty or is not a Fritter Profile. <a href="/"> Try again! </a>
</div>`
});
}
} else if (view === 'user') {
try {
// resolve the name in case a shortname is used
Expand Down