mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Fixes to Polycentric flows.
This commit is contained in:
parent
11b8914615
commit
fe02197bd8
11 changed files with 65 additions and 26 deletions
|
@ -54,6 +54,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.Serializable
|
||||
import okhttp3.internal.platform.Platform
|
||||
|
||||
@Serializable
|
||||
data class PolycentricProfile(val system: PublicKey, val systemState: SystemState, val ownedClaims: List<OwnedClaim>);
|
||||
|
@ -298,7 +299,7 @@ class ChannelFragment : MainFragment() {
|
|||
Glide.with(_imageBanner)
|
||||
.clear(_imageBanner);
|
||||
|
||||
_taskLoadPolycentricProfile.run(parameter.id);
|
||||
loadPolycentricProfile(parameter.id, parameter.url)
|
||||
};
|
||||
|
||||
_url = parameter.url;
|
||||
|
@ -311,7 +312,7 @@ class ChannelFragment : MainFragment() {
|
|||
Glide.with(_imageBanner)
|
||||
.clear(_imageBanner);
|
||||
|
||||
_taskLoadPolycentricProfile.run(parameter.channel.id);
|
||||
loadPolycentricProfile(parameter.channel.id, parameter.channel.url)
|
||||
};
|
||||
|
||||
_url = parameter.channel.url;
|
||||
|
@ -327,6 +328,18 @@ class ChannelFragment : MainFragment() {
|
|||
_tabs.selectTab(_tabs.getTabAt(selectedTabIndex));
|
||||
}
|
||||
|
||||
private fun loadPolycentricProfile(id: PlatformID, url: String) {
|
||||
val cachedPolycentricProfile = PolycentricCache.instance.getCachedProfile(url, true);
|
||||
if (cachedPolycentricProfile != null) {
|
||||
setPolycentricProfile(cachedPolycentricProfile, animate = true)
|
||||
if (cachedPolycentricProfile.expired) {
|
||||
_taskLoadPolycentricProfile.run(id);
|
||||
}
|
||||
} else {
|
||||
_taskLoadPolycentricProfile.run(id);
|
||||
}
|
||||
}
|
||||
|
||||
private fun setLoading(isLoading: Boolean) {
|
||||
if (_isLoading == isLoading) {
|
||||
return;
|
||||
|
@ -448,8 +461,6 @@ class ChannelFragment : MainFragment() {
|
|||
}
|
||||
|
||||
private fun setPolycentricProfile(cachedPolycentricProfile: PolycentricCache.CachedPolycentricProfile?, animate: Boolean) {
|
||||
Log.i(TAG, "setPolycentricProfile(cachedPolycentricProfile = $cachedPolycentricProfile, animate = $animate)")
|
||||
|
||||
val dp_35 = 35.dp(resources)
|
||||
val profile = cachedPolycentricProfile?.profile;
|
||||
val avatar = profile?.systemState?.avatar?.selectBestImage(dp_35 * dp_35)
|
||||
|
|
|
@ -596,9 +596,12 @@ class PostDetailFragment : MainFragment {
|
|||
|
||||
private fun fetchPolycentricProfile() {
|
||||
val author = _post?.author ?: _postOverview?.author ?: return;
|
||||
val cachedPolycentricProfile = PolycentricCache.instance.getCachedProfile(author.url);
|
||||
val cachedPolycentricProfile = PolycentricCache.instance.getCachedProfile(author.url, true);
|
||||
if (cachedPolycentricProfile != null) {
|
||||
setPolycentricProfile(cachedPolycentricProfile, animate = false);
|
||||
if (cachedPolycentricProfile.expired) {
|
||||
_taskLoadPolycentricProfile.run(author.id);
|
||||
}
|
||||
} else {
|
||||
setPolycentricProfile(null, animate = false);
|
||||
_taskLoadPolycentricProfile.run(author.id);
|
||||
|
|
|
@ -992,14 +992,17 @@ class VideoDetailView : ConstraintLayout {
|
|||
_descriptionContainer.visibility = View.GONE;
|
||||
|
||||
_creatorThumbnail.setThumbnail(video.author.thumbnail, false);
|
||||
_channelName.text = video.author.name;
|
||||
|
||||
val cachedPolycentricProfile = PolycentricCache.instance.getCachedProfile(video.author.url);
|
||||
val cachedPolycentricProfile = PolycentricCache.instance.getCachedProfile(video.author.url, true);
|
||||
if (cachedPolycentricProfile != null) {
|
||||
setPolycentricProfile(cachedPolycentricProfile, animate = false);
|
||||
if (cachedPolycentricProfile.expired) {
|
||||
_taskLoadPolycentricProfile.run(video.author.id);
|
||||
}
|
||||
} else {
|
||||
setPolycentricProfile(null, animate = false);
|
||||
_taskLoadPolycentricProfile.run(video.author.id);
|
||||
_channelName.text = video.author.name;
|
||||
}
|
||||
|
||||
_player.clear();
|
||||
|
@ -1146,7 +1149,7 @@ class VideoDetailView : ConstraintLayout {
|
|||
setDescription(video.description.fixHtmlLinks());
|
||||
_creatorThumbnail.setThumbnail(video.author.thumbnail, false);
|
||||
|
||||
val cachedPolycentricProfile = PolycentricCache.instance.getCachedProfile(video.author.url);
|
||||
val cachedPolycentricProfile = PolycentricCache.instance.getCachedProfile(video.author.url, true);
|
||||
if (cachedPolycentricProfile != null) {
|
||||
setPolycentricProfile(cachedPolycentricProfile, animate = false);
|
||||
} else {
|
||||
|
@ -2169,6 +2172,11 @@ class VideoDetailView : ConstraintLayout {
|
|||
_creatorThumbnail.setHarborAvailable(profile != null, animate);
|
||||
}
|
||||
|
||||
val username = cachedPolycentricProfile?.profile?.systemState?.username
|
||||
if (username != null) {
|
||||
_channelName.text = username
|
||||
}
|
||||
|
||||
_monetization.setPolycentricProfile(cachedPolycentricProfile, animate);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,9 @@ class PolycentricCache {
|
|||
ContentType.MEMBERSHIP_URLS.value,
|
||||
ContentType.DONATION_DESTINATIONS.value
|
||||
)
|
||||
).eventsList.map { e -> SignedEvent.fromProto(e) };
|
||||
).eventsList.map { e -> SignedEvent.fromProto(e) }
|
||||
.groupBy { e -> e.event.contentType }
|
||||
.map { (_, events) -> events.maxBy { it.event.unixMilliseconds ?: 0 } };
|
||||
|
||||
val storageSystemState = StorageTypeSystemState.create()
|
||||
for (signedEvent in signedProfileEvents) {
|
||||
|
|
|
@ -82,7 +82,6 @@ class SubscriptionViewHolder : ViewHolder {
|
|||
this.subscription = sub;
|
||||
|
||||
_creatorThumbnail.setThumbnail(sub.channel.thumbnail, false);
|
||||
_taskLoadProfile.run(sub.channel.id);
|
||||
_textName.text = sub.channel.name;
|
||||
bindViewMetrics(sub);
|
||||
_platformIndicator.setPlatformFromClientID(sub.channel.id.pluginId);
|
||||
|
@ -93,6 +92,8 @@ class SubscriptionViewHolder : ViewHolder {
|
|||
if (cachedProfile.expired) {
|
||||
_taskLoadProfile.run(sub.channel.id);
|
||||
}
|
||||
} else {
|
||||
_taskLoadProfile.run(sub.channel.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ open class PreviewVideoView : LinearLayout {
|
|||
.placeholder(R.drawable.placeholder_channel_thumbnail)
|
||||
.into(_imageChannel);
|
||||
}
|
||||
_taskLoadProfile.run(content.author.id);
|
||||
|
||||
_textChannelName.text = content.author.name
|
||||
|
||||
val cachedProfile = PolycentricCache.instance.getCachedProfile(content.author.url, true);
|
||||
|
@ -192,6 +192,8 @@ open class PreviewVideoView : LinearLayout {
|
|||
if (cachedProfile.expired) {
|
||||
_taskLoadProfile.run(content.author.id);
|
||||
}
|
||||
} else {
|
||||
_taskLoadProfile.run(content.author.id);
|
||||
}
|
||||
|
||||
_imageChannel?.clipToOutline = true;
|
||||
|
|
|
@ -66,7 +66,6 @@ class CreatorViewHolder(private val _viewGroup: ViewGroup, private val _tiny: Bo
|
|||
_taskLoadProfile.cancel();
|
||||
|
||||
_creatorThumbnail.setThumbnail(authorLink.thumbnail, false);
|
||||
_taskLoadProfile.run(authorLink.id);
|
||||
_textName.text = authorLink.name;
|
||||
|
||||
val cachedProfile = PolycentricCache.instance.getCachedProfile(authorLink.url, true);
|
||||
|
@ -75,6 +74,8 @@ class CreatorViewHolder(private val _viewGroup: ViewGroup, private val _tiny: Bo
|
|||
if (cachedProfile.expired) {
|
||||
_taskLoadProfile.run(authorLink.id);
|
||||
}
|
||||
} else {
|
||||
_taskLoadProfile.run(authorLink.id);
|
||||
}
|
||||
|
||||
if(authorLink.subscribers == null || (authorLink.subscribers ?: 0) <= 0L)
|
||||
|
|
|
@ -52,7 +52,6 @@ class SubscriptionBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter.
|
|||
_channel = subscription.channel;
|
||||
|
||||
_creatorThumbnail.setThumbnail(subscription.channel.thumbnail, false);
|
||||
_taskLoadProfile.run(subscription.channel.id);
|
||||
_name.text = subscription.channel.name;
|
||||
|
||||
val cachedProfile = PolycentricCache.instance.getCachedProfile(subscription.channel.url, true);
|
||||
|
@ -61,6 +60,8 @@ class SubscriptionBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter.
|
|||
if (cachedProfile.expired) {
|
||||
_taskLoadProfile.run(subscription.channel.id);
|
||||
}
|
||||
} else {
|
||||
_taskLoadProfile.run(subscription.channel.id);
|
||||
}
|
||||
|
||||
_subscription = subscription;
|
||||
|
|
|
@ -3,11 +3,17 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.futo.platformplayer.views.SupportView
|
||||
android:id="@+id/support"
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.futo.platformplayer.views.SupportView
|
||||
android:id="@+id/support"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_monetization"
|
||||
|
|
|
@ -15,11 +15,18 @@
|
|||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<com.futo.platformplayer.views.SupportView
|
||||
android:id="@+id/support"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/topbar"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<com.futo.platformplayer.views.SupportView
|
||||
android:id="@+id/support"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</ScrollView>
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,11 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="18dp"
|
||||
android:showDividers="middle"
|
||||
|
@ -187,5 +185,4 @@
|
|||
android:divider="@drawable/divider_transparent_vertical_8dp">
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
Loading…
Add table
Reference in a new issue