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

optimize: stop loading after followers/following page deactive #70

Merged
merged 2 commits into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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