mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Merge
This commit is contained in:
commit
d4317ff06f
9 changed files with 58 additions and 32 deletions
|
@ -6,6 +6,7 @@ import com.futo.platformplayer.api.media.platforms.js.JSClient
|
|||
import com.futo.platformplayer.constructs.Event1
|
||||
import com.futo.platformplayer.constructs.Event2
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
import com.futo.platformplayer.states.StateApp
|
||||
|
||||
class PlatformClientPool {
|
||||
private val _parent: JSClient;
|
||||
|
@ -51,6 +52,11 @@ class PlatformClientPool {
|
|||
if(reserved == null && _pool.size < capacity) {
|
||||
Logger.i(TAG, "Started additional [${_parent.name}] client in pool [${_poolName}] (${_pool.size + 1}/${capacity})");
|
||||
reserved = _parent.getCopy();
|
||||
|
||||
reserved?.onCaptchaException?.subscribe { client, ex ->
|
||||
StateApp.instance.handleCaptchaException(client, ex);
|
||||
};
|
||||
|
||||
reserved?.initialize();
|
||||
_pool[reserved!!] = _poolCounter;
|
||||
}
|
||||
|
|
|
@ -346,24 +346,24 @@ class PostDetailFragment : MainFragment {
|
|||
|
||||
_rating.visibility = VISIBLE;
|
||||
_rating.setRating(RatingLikeDislikes(likes, dislikes), hasLiked, hasDisliked);
|
||||
_rating.onLikeDislikeUpdated.subscribe(this) { processHandle, newHasLiked, newHasDisliked ->
|
||||
if (newHasLiked) {
|
||||
processHandle.opinion(ref, Opinion.like);
|
||||
} else if (newHasDisliked) {
|
||||
processHandle.opinion(ref, Opinion.dislike);
|
||||
_rating.onLikeDislikeUpdated.subscribe(this) { args ->
|
||||
if (args.hasLiked) {
|
||||
args.processHandle.opinion(ref, Opinion.like);
|
||||
} else if (args.hasDisliked) {
|
||||
args.processHandle.opinion(ref, Opinion.dislike);
|
||||
} else {
|
||||
processHandle.opinion(ref, Opinion.neutral);
|
||||
args.processHandle.opinion(ref, Opinion.neutral);
|
||||
}
|
||||
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
processHandle.fullyBackfillServers();
|
||||
args.processHandle.fullyBackfillServers();
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to backfill servers", e)
|
||||
}
|
||||
}
|
||||
|
||||
StatePolycentric.instance.updateLikeMap(ref, newHasLiked, newHasDisliked)
|
||||
StatePolycentric.instance.updateLikeMap(ref, args.hasLiked, args.hasDisliked)
|
||||
};
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
|
|
|
@ -1042,24 +1042,24 @@ class VideoDetailView : ConstraintLayout {
|
|||
withContext(Dispatchers.Main) {
|
||||
_rating.visibility = View.VISIBLE;
|
||||
_rating.setRating(RatingLikeDislikes(likes, dislikes), hasLiked, hasDisliked);
|
||||
_rating.onLikeDislikeUpdated.subscribe(this) { processHandle, newHasLiked, newHasDisliked ->
|
||||
if (newHasLiked) {
|
||||
processHandle.opinion(ref, Opinion.like);
|
||||
} else if (newHasDisliked) {
|
||||
processHandle.opinion(ref, Opinion.dislike);
|
||||
_rating.onLikeDislikeUpdated.subscribe(this) { args ->
|
||||
if (args.hasLiked) {
|
||||
args.processHandle.opinion(ref, Opinion.like);
|
||||
} else if (args.hasDisliked) {
|
||||
args.processHandle.opinion(ref, Opinion.dislike);
|
||||
} else {
|
||||
processHandle.opinion(ref, Opinion.neutral);
|
||||
args.processHandle.opinion(ref, Opinion.neutral);
|
||||
}
|
||||
|
||||
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
processHandle.fullyBackfillServers();
|
||||
args.processHandle.fullyBackfillServers();
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to backfill servers", e)
|
||||
}
|
||||
}
|
||||
|
||||
StatePolycentric.instance.updateLikeMap(ref, newHasLiked, newHasDisliked)
|
||||
StatePolycentric.instance.updateLikeMap(ref, args.hasLiked, args.hasDisliked)
|
||||
};
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
|
|
|
@ -37,14 +37,13 @@ class StateTelemetry {
|
|||
BuildConfig.BUILD_TYPE,
|
||||
BuildConfig.DEBUG,
|
||||
BuildConfig.IS_UNSTABLE_BUILD,
|
||||
Instant.now().epochSecond,
|
||||
Build.BRAND,
|
||||
Build.MANUFACTURER,
|
||||
Build.MODEL
|
||||
);
|
||||
|
||||
val headers = hashMapOf(
|
||||
"Content-Type" to "text/plain"
|
||||
"Content-Type" to "application/json"
|
||||
);
|
||||
|
||||
val json = Json.encodeToString(telemetry);
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import com.futo.platformplayer.*
|
||||
import com.futo.platformplayer.api.media.models.comments.IPlatformComment
|
||||
|
@ -35,12 +36,14 @@ class CommentViewHolder : ViewHolder {
|
|||
private val _buttonReplies: PillButton;
|
||||
private val _layoutRating: LinearLayout;
|
||||
private val _pillRatingLikesDislikes: PillRatingLikesDislikes;
|
||||
private val _layoutComment: ConstraintLayout;
|
||||
|
||||
var onClick = Event1<IPlatformComment>();
|
||||
var comment: IPlatformComment? = null
|
||||
private set;
|
||||
|
||||
constructor(viewGroup: ViewGroup) : super(LayoutInflater.from(viewGroup.context).inflate(R.layout.list_comment, viewGroup, false)) {
|
||||
_layoutComment = itemView.findViewById(R.id.layout_comment);
|
||||
_creatorThumbnail = itemView.findViewById(R.id.image_thumbnail);
|
||||
_textAuthor = itemView.findViewById(R.id.text_author);
|
||||
_textMetadata = itemView.findViewById(R.id.text_metadata);
|
||||
|
@ -53,29 +56,31 @@ class CommentViewHolder : ViewHolder {
|
|||
_layoutRating = itemView.findViewById(R.id.layout_rating);
|
||||
_pillRatingLikesDislikes = itemView.findViewById(R.id.rating);
|
||||
|
||||
_pillRatingLikesDislikes.onLikeDislikeUpdated.subscribe { processHandle, hasLiked, hasDisliked ->
|
||||
_pillRatingLikesDislikes.onLikeDislikeUpdated.subscribe { args ->
|
||||
val c = comment
|
||||
if (c !is PolycentricPlatformComment) {
|
||||
throw Exception("Not implemented for non polycentric comments")
|
||||
}
|
||||
|
||||
if (hasLiked) {
|
||||
processHandle.opinion(c.reference, Opinion.like);
|
||||
} else if (hasDisliked) {
|
||||
processHandle.opinion(c.reference, Opinion.dislike);
|
||||
if (args.hasLiked) {
|
||||
args.processHandle.opinion(c.reference, Opinion.like);
|
||||
} else if (args.hasDisliked) {
|
||||
args.processHandle.opinion(c.reference, Opinion.dislike);
|
||||
} else {
|
||||
processHandle.opinion(c.reference, Opinion.neutral);
|
||||
args.processHandle.opinion(c.reference, Opinion.neutral);
|
||||
}
|
||||
|
||||
_layoutComment.alpha = if (args.dislikes > 2 && args.dislikes / (args.likes + args.dislikes) >= 0.7) 0.5f else 1.0f;
|
||||
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
processHandle.fullyBackfillServers();
|
||||
args.processHandle.fullyBackfillServers();
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to backfill servers.", e)
|
||||
}
|
||||
}
|
||||
|
||||
StatePolycentric.instance.updateLikeMap(c.reference, hasLiked, hasDisliked)
|
||||
StatePolycentric.instance.updateLikeMap(c.reference, args.hasLiked, args.hasDisliked)
|
||||
};
|
||||
|
||||
_buttonReplies.onClick.subscribe {
|
||||
|
@ -98,6 +103,13 @@ class CommentViewHolder : ViewHolder {
|
|||
_textMetadata.visibility = View.GONE;
|
||||
}
|
||||
|
||||
val rating = comment.rating;
|
||||
if (rating is RatingLikeDislikes) {
|
||||
_layoutComment.alpha = if (rating.dislikes > 0 && rating.dislikes / (rating.likes + rating.dislikes) >= 0.7) 0.5f else 1.0f;
|
||||
} else {
|
||||
_layoutComment.alpha = 1.0f;
|
||||
}
|
||||
|
||||
_textBody.text = comment.message.fixHtmlLinks();
|
||||
|
||||
if (readonly) {
|
||||
|
|
|
@ -12,11 +12,20 @@ import com.futo.platformplayer.R
|
|||
import com.futo.platformplayer.api.media.models.ratings.IRating
|
||||
import com.futo.platformplayer.api.media.models.ratings.RatingLikeDislikes
|
||||
import com.futo.platformplayer.api.media.models.ratings.RatingLikes
|
||||
import com.futo.platformplayer.constructs.Event1
|
||||
import com.futo.platformplayer.constructs.Event3
|
||||
import com.futo.platformplayer.states.StatePolycentric
|
||||
import com.futo.platformplayer.toHumanNumber
|
||||
import com.futo.polycentric.core.ProcessHandle
|
||||
|
||||
data class OnLikeDislikeUpdatedArgs(
|
||||
val processHandle: ProcessHandle,
|
||||
val likes: Long,
|
||||
val hasLiked: Boolean,
|
||||
val dislikes: Long,
|
||||
val hasDisliked: Boolean,
|
||||
);
|
||||
|
||||
class PillRatingLikesDislikes : LinearLayout {
|
||||
private val _textLikes: TextView;
|
||||
private val _textDislikes: TextView;
|
||||
|
@ -29,7 +38,7 @@ class PillRatingLikesDislikes : LinearLayout {
|
|||
private var _dislikes = 0L;
|
||||
private var _hasDisliked = false;
|
||||
|
||||
val onLikeDislikeUpdated = Event3<ProcessHandle, Boolean, Boolean>();
|
||||
val onLikeDislikeUpdated = Event1<OnLikeDislikeUpdatedArgs>();
|
||||
|
||||
constructor(context : Context, attrs : AttributeSet?) : super(context, attrs) {
|
||||
LayoutInflater.from(context).inflate(R.layout.rating_likesdislikes, this, true);
|
||||
|
@ -76,7 +85,7 @@ class PillRatingLikesDislikes : LinearLayout {
|
|||
|
||||
_textLikes.text = _likes.toHumanNumber();
|
||||
updateColors();
|
||||
onLikeDislikeUpdated.emit(processHandle, _hasLiked, _hasDisliked);
|
||||
onLikeDislikeUpdated.emit(OnLikeDislikeUpdatedArgs(processHandle, _likes, _hasLiked, _dislikes, _hasDisliked));
|
||||
}
|
||||
|
||||
fun dislike(processHandle: ProcessHandle) {
|
||||
|
@ -96,7 +105,7 @@ class PillRatingLikesDislikes : LinearLayout {
|
|||
|
||||
_textDislikes.text = _dislikes.toHumanNumber();
|
||||
updateColors();
|
||||
onLikeDislikeUpdated.emit(processHandle, _hasLiked, _hasDisliked);
|
||||
onLikeDislikeUpdated.emit(OnLikeDislikeUpdatedArgs(processHandle, _likes, _hasLiked, _dislikes, _hasDisliked));
|
||||
}
|
||||
|
||||
private fun updateColors() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1c34bb016378805ca24883ed55573dcd862309cf
|
||||
Subproject commit eff873edf344663f7dd2741ea9f1b8eca17afa24
|
|
@ -1 +1 @@
|
|||
Subproject commit 0a0b84437015cb282fae49e60ae69afe1b45768d
|
||||
Subproject commit 29665c24a1f645b17ee92d25018dc96b558235fe
|
|
@ -1 +1 @@
|
|||
Subproject commit 636d17f0adb112c4ad139b71aac2eef652e04036
|
||||
Subproject commit 1079dd394f71921a968509bc16292ac1e80e3f9c
|
Loading…
Add table
Reference in a new issue