<commit_before><template>
    <button class="btn btn-success" @click="handler"><i :class="[iconClass]" class="fa-fw mr-2"></i>收藏社團</button>
</template>

<script>
    export default {
        props: {
            favorited: {
                default: false
            },
            clubId: {
                required: true,
            },
            clubName: {
                type: String,
                required: true
            }
        },
        data: function () {
            return {
                loading: false,
                isFavorited: this.favorited
            }
        },
        created() {
            console.log(this.isFavorited + '/' + this.favorited)
            //在 ClubCards 中，上面的 data 部分無法順利初始化，因此500ms之後再次嘗試進行
            // _.delay(() => {
            //     this.isFavorited = this.favorited;
            // }, 500)
        },
        computed: {
            iconClass: function () {
                if (this.loading) {
                    return 'fas fa-spinner fa-pulse';
                }
                return this.isFavorited ? 'fas fa-star' : 'far fa-star'
            }
        },
        methods: {
            handler: function () {
                this.loading = true;
                if (!this.isFavorited) {
                    this.addFavoriteClub()
                } else {
                    this.removeFavoriteClub()
                }
            },
            addFavoriteClub: function () {
                let addFavoriteClubAPIUrl = Laravel.baseUrl + '/api/add-favorite-club/' + this.clubId;
                axios.post(addFavoriteClubAPIUrl).then(response => {
                    this.isFavorited = true;<commit_msg>Add hot fix code of favorite status<commit_after><template>
    <button class="btn btn-success" @click="handler"><i :class="[iconClass]" class="fa-fw mr-2"></i>收藏社團</button>
</template>

<script>
    export default {
        props: {
            favorited: {
                default: false
            },
            clubId: {
                required: true,
            },
            clubName: {
                type: String,
                required: true
            }
        },
        data: function () {
            return {
                loading: false,
                isFavorited: this.favorited
            }
        },
        created() {
            //FIXME: 在 ClubCards 中，上面的 data 部分無法順利初始化，因此500ms之後再次嘗試進行
            _.delay(() => {
                this.isFavorited = this.favorited;
            }, 500)
        },
        computed: {
            iconClass: function () {
                if (this.loading) {
                    return 'fas fa-spinner fa-pulse';
                }
                return this.isFavorited ? 'fas fa-star' : 'far fa-star'
            }
        },
        methods: {
            handler: function () {
                this.loading = true;
                if (!this.isFavorited) {
                    this.addFavoriteClub()
                } else {
                    this.removeFavoriteClub()
                }
            },
            addFavoriteClub: function () {
                let addFavoriteClubAPIUrl = Laravel.baseUrl + '/api/add-favorite-club/' + this.clubId;
                axios.post(addFavoriteClubAPIUrl).then(response => {
                    this.isFavorited = true;
{'fraction_non_alphanumeric': 0.11198309689103532, 'fraction_numerical': 0.004225777241171144, 'mean_word_length': 1.1216389244558258, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '7383199', 'n_tokens_mistral': 970, 'n_tokens_neox': 923, 'n_words': 160}