<commit_before>import Vue from 'vue';
import { Component, Inject, Prop } from 'vue-property-decorator';
import { State } from 'vuex-class';
import { findRequiredVueParent } from '../../../../../utils/vue';
import { CommentVideoModal } from '../../../../../_common/comment/video/modal/modal.service';
import { CommentVideo } from '../../../../../_common/comment/video/video-model';
import { CommunityChannel } from '../../../../../_common/community/channel/channel.model';
import { Community } from '../../../../../_common/community/community.model';
import AppCommunityPill from '../../../../../_common/community/pill/pill.vue';
import AppContentViewer from '../../../../../_common/content/content-viewer/content-viewer.vue';
import { Environment } from '../../../../../_common/environment/environment.service';
import { EventItem } from '../../../../../_common/event-item/event-item.model';
import AppFadeCollapse from '../../../../../_common/fade-collapse/fade-collapse.vue';
import { number } from '../../../../../_common/filters/number';
import { FiresidePostCommunity } from '../../../../../_common/fireside/post/community/community.model';
import { FiresidePost } from '../../../../../_common/fireside/post/post-model';
import { Navigate } from '../../../../../_common/navigate/navigate.service';
import AppPill from '../../../../../_common/pill/pill.vue';
import { Screen } from '../../../../../_common/screen/screen-service';
import AppUserCardHover from '../../../../../_common/user/card/hover/hover.vue';
import AppUserFollowWidget from '../../../../../_common/user/follow/widget.vue';
import AppUserAvatar from '../../../../../_common/user/user-avatar/user-avatar.vue';
import AppUserVerifiedTick from '../../../../../_common/user/verified-tick/verified-tick.vue';
import { Store } from '../../../../store';
import AppEventItemControls from '../../../event-item/controls/controls.vue';
import AppPollVoting from '../../../poll/voting/voting.vue';
import AppActivityFeedCommentVideo from '../comment-video/comment-video.vue';
import AppActivityFeedDevlogPostMedia from '../devlog-post/media/media.vue';
import AppActivityFeedDevlogPostSketchfab from '../devlog-post/sketchfab/sketchfab.vue';
import AppActivityFeedDevlogPostText from '../devlog-post/text/text.vue';
import AppActivityFeedDevlogPostVideo from '../devlog-post/video/video.vue';
import AppActivityFeedTS from '../feed';
import { feedShouldBlockPost, feedShouldBlockVideo } from '../feed-service';
import AppActivityFeed from '../feed.vue';
import { ActivityFeedItem } from '../item-service';
import { ActivityFeedView } from '../view';
import AppActivityFeedEventItemBlocked from './blocked/blocked.vue';
import AppActivityFeedEventItemTime from './time/time.vue';

const ResizeSensor = require('css-element-queries/src/ResizeSensor');

@Component({
	components: {
		AppActivityFeedEventItemTime,
		AppUserAvatar,
		AppUserFollowWidget,
		AppActivityFeedCommentVideo,
		AppActivityFeedDevlogPostText,
		AppActivityFeedDevlogPostMedia,
		AppActivityFeedDevlogPostSketchfab,
		AppActivityFeedDevlogPostVideo,
		AppEventItemControls,
		AppPollVoting,
		AppUserCardHover,
		AppFadeCollapse,
		AppCommunityPill,
		AppPill,
		AppContentViewer,
		AppUserVerifiedTick,
		AppActivityFeedEventItemBlocked,
	},
	filters: {
		number,
	},
})
export default class AppActivityFeedEventItem extends Vue {
	@Inject()
	feed!: ActivityFeedView;

	@Prop(ActivityFeedItem)
	item!: ActivityFeedItem;

	@State
	app!: Store['app'];

	canToggleLead = false;
	hasBypassedBlock = false;

	private resizeSensor?: any;
	private feedComponent!: AppActivityFeedTS;

	readonly Screen = Screen;
	readonly EventItem = EventItem;

	$el!: HTMLDivElement;

	get isNew() {
		return this.feed.isItemUnread(this.item);
	}

	get isThreadView() {
		return !Screen.isXs;
	}

	get eventItem() {
		return this.item.feedItem as EventItem;
	}

	get isLeadOpen() {
		return this.feed.isItemLeadOpen(this.item);
	}

	get post() {
		if (this.eventItem.type === EventItem.TYPE_POST_ADD) {
			return this.eventItem.action as FiresidePost;
		}
	}

	get video() {
		if (this.eventItem.type === EventItem.TYPE_COMMENT_VIDEO_ADD) {
			return this.eventItem.action as CommentVideo;
		}
	}

	get user() {
		return this.eventItem.user;
	}

	get game() {
		return this.eventItem.game;
	}

	get gameUrl() {
		if (this.game) {
			return this.game.getUrl();
		}

		return undefined;
	}

	get communities() {
		return (this.post && this.post.communities) || [];
	}

	get link() {
		if (this.eventItem.type === EventItem.TYPE_COMMENT_VIDEO_ADD) {
			return null;
		}

		if (this.eventItem.type === EventItem.TYPE_GAME_PUBLISH) {
			const game = this.game!;

			const params: { [key: string]: string } = {
				slug: game.slug,
				id: game.id + '',
			};

			return {
				name: 'discover.games.view.overview',
				params: params,
			};
		} else if (this.eventItem.type === EventItem.TYPE_POST_ADD) {
			const post = this.post!;
			return post.routeLocation;
		}

		return null;
	}

	get linkResolved() {
		if (!this.link) {
			return '';
		}
		return this.$router.resolve(this.link).href;
	}

	get shouldShowFollow() {
		if (this.isBlocked) {
			return false;
		}

		// Don't show follow for game posts. Only for user posts.
		if (!this.feed.shouldShowFollow || !this.post || this.post.game) {
			return false;
		}

		// Don't show follow if already following.
		if (!this.user || this.user.is_following) {
			return false;
		}

		return true;
	}

	get shouldShowManage() {
		return this.post && this.post.isManageableByUser(this.app.user);<commit_msg>Fix blocked follow in community feeds (#435)<commit_after>import Vue from 'vue';
import { Component, Inject, Prop } from 'vue-property-decorator';
import { State } from 'vuex-class';
import { findRequiredVueParent } from '../../../../../utils/vue';
import { CommentVideoModal } from '../../../../../_common/comment/video/modal/modal.service';
import { CommentVideo } from '../../../../../_common/comment/video/video-model';
import { CommunityChannel } from '../../../../../_common/community/channel/channel.model';
import { Community } from '../../../../../_common/community/community.model';
import AppCommunityPill from '../../../../../_common/community/pill/pill.vue';
import AppContentViewer from '../../../../../_common/content/content-viewer/content-viewer.vue';
import { Environment } from '../../../../../_common/environment/environment.service';
import { EventItem } from '../../../../../_common/event-item/event-item.model';
import AppFadeCollapse from '../../../../../_common/fade-collapse/fade-collapse.vue';
import { number } from '../../../../../_common/filters/number';
import { FiresidePostCommunity } from '../../../../../_common/fireside/post/community/community.model';
import { FiresidePost } from '../../../../../_common/fireside/post/post-model';
import { Navigate } from '../../../../../_common/navigate/navigate.service';
import AppPill from '../../../../../_common/pill/pill.vue';
import { Screen } from '../../../../../_common/screen/screen-service';
import AppUserCardHover from '../../../../../_common/user/card/hover/hover.vue';
import AppUserFollowWidget from '../../../../../_common/user/follow/widget.vue';
import AppUserAvatar from '../../../../../_common/user/user-avatar/user-avatar.vue';
import AppUserVerifiedTick from '../../../../../_common/user/verified-tick/verified-tick.vue';
import { Store } from '../../../../store';
import AppEventItemControls from '../../../event-item/controls/controls.vue';
import AppPollVoting from '../../../poll/voting/voting.vue';
import AppActivityFeedCommentVideo from '../comment-video/comment-video.vue';
import AppActivityFeedDevlogPostMedia from '../devlog-post/media/media.vue';
import AppActivityFeedDevlogPostSketchfab from '../devlog-post/sketchfab/sketchfab.vue';
import AppActivityFeedDevlogPostText from '../devlog-post/text/text.vue';
import AppActivityFeedDevlogPostVideo from '../devlog-post/video/video.vue';
import AppActivityFeedTS from '../feed';
import { feedShouldBlockPost, feedShouldBlockVideo } from '../feed-service';
import AppActivityFeed from '../feed.vue';
import { ActivityFeedItem } from '../item-service';
import { ActivityFeedView } from '../view';
import AppActivityFeedEventItemBlocked from './blocked/blocked.vue';
import AppActivityFeedEventItemTime from './time/time.vue';

const ResizeSensor = require('css-element-queries/src/ResizeSensor');

@Component({
	components: {
		AppActivityFeedEventItemTime,
		AppUserAvatar,
		AppUserFollowWidget,
		AppActivityFeedCommentVideo,
		AppActivityFeedDevlogPostText,
		AppActivityFeedDevlogPostMedia,
		AppActivityFeedDevlogPostSketchfab,
		AppActivityFeedDevlogPostVideo,
		AppEventItemControls,
		AppPollVoting,
		AppUserCardHover,
		AppFadeCollapse,
		AppCommunityPill,
		AppPill,
		AppContentViewer,
		AppUserVerifiedTick,
		AppActivityFeedEventItemBlocked,
	},
	filters: {
		number,
	},
})
export default class AppActivityFeedEventItem extends Vue {
	@Inject()
	feed!: ActivityFeedView;

	@Prop(ActivityFeedItem)
	item!: ActivityFeedItem;

	@State
	app!: Store['app'];

	canToggleLead = false;
	hasBypassedBlock = false;

	private resizeSensor?: any;
	private feedComponent!: AppActivityFeedTS;

	readonly Screen = Screen;
	readonly EventItem = EventItem;

	$el!: HTMLDivElement;

	get isNew() {
		return this.feed.isItemUnread(this.item);
	}

	get isThreadView() {
		return !Screen.isXs;
	}

	get eventItem() {
		return this.item.feedItem as EventItem;
	}

	get isLeadOpen() {
		return this.feed.isItemLeadOpen(this.item);
	}

	get post() {
		if (this.eventItem.type === EventItem.TYPE_POST_ADD) {
			return this.eventItem.action as FiresidePost;
		}
	}

	get video() {
		if (this.eventItem.type === EventItem.TYPE_COMMENT_VIDEO_ADD) {
			return this.eventItem.action as CommentVideo;
		}
	}

	get user() {
		return this.eventItem.user;
	}

	get game() {
		return this.eventItem.game;
	}

	get gameUrl() {
		if (this.game) {
			return this.game.getUrl();
		}

		return undefined;
	}

	get communities() {
		return (this.post && this.post.communities) || [];
	}

	get link() {
		if (this.eventItem.type === EventItem.TYPE_COMMENT_VIDEO_ADD) {
			return null;
		}

		if (this.eventItem.type === EventItem.TYPE_GAME_PUBLISH) {
			const game = this.game!;

			const params: { [key: string]: string } = {
				slug: game.slug,
				id: game.id + '',
			};

			return {
				name: 'discover.games.view.overview',
				params: params,
			};
		} else if (this.eventItem.type === EventItem.TYPE_POST_ADD) {
			const post = this.post!;
			return post.routeLocation;
		}

		return null;
	}

	get linkResolved() {
		if (!this.link) {
			return '';
		}
		return this.$router.resolve(this.link).href;
	}

	get shouldShowFollow() {
		if (this.isBlocked || this.post?.user.blocked_you) {
			return false;
		}

		// Don't show follow for game posts. Only for user posts.
		if (!this.feed.shouldShowFollow || !this.post || this.post.game) {
			return false;
		}

		// Don't show follow if already following.
		if (!this.user || this.user.is_following) {
			return false;
		}

		return true;
	}

	get shouldShowManage() {
		return this.post && this.post.isManageableByUser(this.app.user);
{'fraction_non_alphanumeric': 0.1778751565015203, 'fraction_numerical': 0.00026828832051511357, 'mean_word_length': 3.3889324960753533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5625995', 'n_tokens_mistral': 3784, 'n_tokens_neox': 3552, 'n_words': 714}