Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Commit

Permalink
optimize: stop loading after followers/following page deactive
Browse files Browse the repository at this point in the history
  • Loading branch information
Candinya committed Oct 8, 2021
1 parent 03b1193 commit e9b5d9d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 28 deletions.
39 changes: 25 additions & 14 deletions src/views/Followers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default class Followers extends Vue {
rns: string = '';
ethAddress: string = '';
lastRoute: string = '';
isPageActive: boolean = false;
async setupAddress() {
const address = <string>this.$route.params.address;
Expand All @@ -92,23 +93,28 @@ export default class Followers extends Vue {
if (rss3 && followersList) {
for (const item of followersList) {
try {
const profile = (await rss3.profile.get(item)) || {};
this.followerList.push({
avatar: profile.avatar?.[0] || config.defaultAvatar,
username: profile.name || '',
bio: profile.bio || '',
address: item,
displayAddress: this.filter(item),
rns: '',
});
} catch (e) {
console.log(item, e);
}
this.followerList.push({
avatar: config.defaultAvatar,
username: '',
bio: '',
address: item,
displayAddress: this.filter(item),
rns: '',
});
}
setTimeout(async () => {
for (const item of this.followerList) {
item.rns = (await RNSUtils.addr2Name(item.address)).replace(config.rns.suffix, '');
if (this.isPageActive) {
try {
const profile = (await rss3.profile.get(item.address)) || {};
item.avatar = profile.avatar?.[0] || config.defaultAvatar;
item.username = profile.name || '';
item.bio = profile.bio || '';
item.rns = (await RNSUtils.addr2Name(item.address)).replace(config.rns.suffix, '');
} catch (e) {
console.log(item, e);
}
}
}
});
}
Expand Down Expand Up @@ -154,6 +160,7 @@ export default class Followers extends Vue {
}
async activated() {
this.isPageActive = true;
await this.setupAddress();
setTimeout(async () => {
await this.setupTheme();
Expand All @@ -164,6 +171,10 @@ export default class Followers extends Vue {
}
}, 0);
}
async deactivated() {
this.isPageActive = false;
}
}
</script>

Expand Down
39 changes: 25 additions & 14 deletions src/views/Followings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default class Followings extends Vue {
rns: string = '';
ethAddress: string = '';
lastRoute: string = '';
isPageActive: boolean = false;
async setupAddress() {
const address = <string>this.$route.params.address;
Expand All @@ -92,23 +93,28 @@ export default class Followings extends Vue {
if (rss3 && followersList) {
for (const item of followersList) {
try {
const profile = await rss3.profile.get(item);
this.followingList.push({
avatar: profile?.avatar?.[0] || config.defaultAvatar,
username: profile?.name || '',
bio: profile.bio || '',
address: item,
displayAddress: this.filter(item),
rns: '',
});
} catch (e) {
console.log(item, e);
}
this.followingList.push({
avatar: config.defaultAvatar,
username: '',
bio: '',
address: item,
displayAddress: this.filter(item),
rns: '',
});
}
setTimeout(async () => {
for (const item of this.followingList) {
item.rns = (await RNSUtils.addr2Name(item.address)).replace(config.rns.suffix, '');
if (this.isPageActive) {
try {
const profile = (await rss3.profile.get(item.address)) || {};
item.avatar = profile.avatar?.[0] || config.defaultAvatar;
item.username = profile.name || '';
item.bio = profile.bio || '';
item.rns = (await RNSUtils.addr2Name(item.address)).replace(config.rns.suffix, '');
} catch (e) {
console.log(item, e);
}
}
}
});
}
Expand Down Expand Up @@ -154,6 +160,7 @@ export default class Followings extends Vue {
}
async activated() {
this.isPageActive = true;
await this.setupAddress();
setTimeout(async () => {
await this.setupTheme();
Expand All @@ -164,6 +171,10 @@ export default class Followings extends Vue {
}
}, 0);
}
async deactivated() {
this.isPageActive = false;
}
}
</script>

Expand Down

0 comments on commit e9b5d9d

Please sign in to comment.