diff --git a/chat/CharacterSearch.vue b/chat/CharacterSearch.vue index 7b3f29b..ac9e380 100644 --- a/chat/CharacterSearch.vue +++ b/chat/CharacterSearch.vue @@ -10,23 +10,29 @@ <filterable-select v-for="item in listItems" :multiple="true" v-model="data[item]" :placeholder="l('filter')" :title="l('characterSearch.' + item)" :options="options[item]" :key="item"> </filterable-select> + + <div v-if="searchString" class="search-string"> + Searching for <span>{{searchString}}</span> + </div> + + <button class="btn btn-outline-secondary" @click.prevent="reset()">Reset</button> </div> <div v-else-if="results" class="results"> <h4>{{l('characterSearch.results')}}</h4> <div v-for="character in results" :key="character.name" :class="'status-' + character.status"> <template v-if="character.status === 'looking'" v-once> <img :src="characterImage(character.name)" v-if="showAvatars"/> - <user :character="character" :showStatus="true"></user> + <user :character="character" :showStatus="true" :match="true"></user> <bbcode :text="character.statusText"></bbcode> </template> - <user v-else :character="character" :showStatus="true" v-once></user> + <user v-else :character="character" :showStatus="true" :match="true" v-once></user> </div> </div> </modal> </template> <script lang="ts"> - import {Component, Hook} from '@f-list/vue-ts'; + import { Component, Hook, Watch } from '@f-list/vue-ts'; import Axios from 'axios'; import CustomDialog from '../components/custom_dialog'; import FilterableSelect from '../components/FilterableSelect.vue'; @@ -37,6 +43,7 @@ import {Character, Connection} from './interfaces'; import l from './localize'; import UserView from './UserView.vue'; + import * as _ from 'lodash'; type Options = { kinks: Kink[], @@ -78,6 +85,8 @@ data: Data = {kinks: [], genders: [], orientations: [], languages: [], furryprefs: [], roles: [], positions: []}; listItems: ReadonlyArray<keyof Data> = ['genders', 'orientations', 'languages', 'furryprefs', 'roles', 'positions']; + searchString = ''; + @Hook('created') async created(): Promise<void> { if(options === undefined) @@ -114,6 +123,21 @@ }); } + + @Watch('data', { deep: true }) + onDataChange(): void { + this.searchString = _.join( + _.map( + _.flatten(_.map(this.data as any)), + (v) => { + return _.get(v, 'name', v); + } + ), + ', ' + ); + } + + filterKink(filter: RegExp, kink: Kink): boolean { if(this.data.kinks.length >= 5) return this.data.kinks.indexOf(kink) !== -1; @@ -124,6 +148,12 @@ return core.state.settings.showAvatars; } + + reset(): void { + this.data = {kinks: [], genders: [], orientations: [], languages: [], furryprefs: [], roles: [], positions: []}; + } + + submit(): void { if(this.results !== undefined) { this.results = undefined; @@ -161,5 +191,16 @@ width: 50px; } } + + .search-string { + margin-bottom: 1rem; + margin-top: 1rem; + margin-left: 0.5rem; + font-size: 80%; + } + + .search-string span { + font-weight: bold; + } } </style> \ No newline at end of file diff --git a/chat/UserView.vue b/chat/UserView.vue index e21c29a..c11c17f 100644 --- a/chat/UserView.vue +++ b/chat/UserView.vue @@ -75,8 +75,10 @@ export default class UserView extends Vue { // tslint:disable-next-line no-unsafe-any no-any this.scoreWatcher = (event: any): void => { + // console.log('scoreWatcher', event); + // tslint:disable-next-line no-unsafe-any no-any - if ((event.character) && (event.character.name === this.character.name)) { + if ((event.character) && (event.character.character.name === this.character.name)) { this.update(); if (this.scoreWatcher) { @@ -112,7 +114,7 @@ export default class UserView extends Vue { this.statusClass = null; this.matchClass = null; - if (this.match) console.log('Update'); + // if (this.match) console.log('Update', this.character.name); if(this.character.isChatOp) { this.rankIcon = 'far fa-gem'; @@ -127,7 +129,7 @@ export default class UserView extends Vue { if ((this.showStatus) || (this.character.status === 'crown')) this.statusClass = `fa-fw ${getStatusIcon(this.character.status)}`; - if (this.match) console.log('Update prematch'); + // if (this.match) console.log('Update prematch', this.character.name); if (this.match) { const cache = core.cache.profileCache.getSync(this.character.name); @@ -135,12 +137,17 @@ export default class UserView extends Vue { if (cache) { this.matchClass = `match-found ${Score.getClasses(cache.matchScore)}`; this.matchScore = cache.matchScore; + + // console.log('Found match data', this.character.name, cache.matchScore); } else { + // console.log('Need match data', this.character.name); + + /* tslint:disable-next-line no-floating-promises */ core.cache.addProfile(this.character.name); } } - if (this.match) console.log('Update post match'); + // if (this.match) console.log('Update post match', this.character.name); const gender = this.character.gender !== undefined ? this.character.gender.toLowerCase() : 'none'; @@ -150,7 +157,7 @@ export default class UserView extends Vue { this.userClass = `user-view gender-${gender}${isBookmark ? ' user-bookmark' : ''}`; - if (this.match) console.log('Update done'); + // if (this.match) console.log('Update done'); } diff --git a/learn/cache-manager.ts b/learn/cache-manager.ts index 06fc6aa..8a03ccb 100644 --- a/learn/cache-manager.ts +++ b/learn/cache-manager.ts @@ -38,10 +38,14 @@ export class CacheManager { protected profileStore?: IndexedStore; - queueForFetching(name: string, skipCacheCheck: boolean = false): void { + async queueForFetching(name: string, skipCacheCheck: boolean = false): Promise<void> { if (!skipCacheCheck) { - if (this.profileCache.get(name)) + const c = await this.profileCache.get(name); + + if (c) { + this.updateAdScoringForProfile(c.character, c.matchScore); return; + } } const key = ProfileCache.nameKey(name); @@ -57,6 +61,8 @@ export class CacheManager { }; this.queue.push(entry); + + // console.log('AddProfileForFetching', name, this.queue.length); } async fetchProfile(name: string): Promise<void> { @@ -104,7 +110,7 @@ export class CacheManager { if (typeof character === 'string') { // console.log('Learn discover', character); - this.queueForFetching(character); + await this.queueForFetching(character); return; } @@ -131,11 +137,17 @@ export class CacheManager { } // re-score - _.each(this.queue, (e: ProfileCacheQueueEntry) => this.calculateScore(e)); + _.each(this.queue, (e: ProfileCacheQueueEntry) => e.score = this.calculateScore(e)); this.queue = _.sortBy(this.queue, 'score'); - return this.queue.pop() as ProfileCacheQueueEntry; + console.log('QUEUE', _.map(this.queue, (q) => `${q.name}: ${q.score}`)); + + const entry = this.queue.pop() as ProfileCacheQueueEntry; + + // console.log('PopFromQueue', entry.name, this.queue.length); + + return entry; } calculateScore(e: ProfileCacheQueueEntry): number { @@ -178,7 +190,7 @@ export class CacheManager { EventBus.$on( 'channel-ad', - (data: ChannelAdEvent) => { + async(data: ChannelAdEvent) => { const message = data.message; const channel = data.channel; @@ -192,7 +204,7 @@ export class CacheManager { ); if (!data.profile) { - this.queueForFetching(message.sender.name, true); + await this.queueForFetching(message.sender.name, true); } // this.addProfile(message.sender.name); diff --git a/learn/character-profiler.ts b/learn/character-profiler.ts index 11b0cf5..80d79c7 100644 --- a/learn/character-profiler.ts +++ b/learn/character-profiler.ts @@ -30,7 +30,10 @@ export class CharacterProfiler { const friendlyScore = this.getInterestScoreForFriendlies(c); // tslint:disable-next-line: number-literal-format binary-expression-operand-order - return ((1.0 * genderScore) + (1.0 * statusScore) + (1.0 * adScore) + (1.0 * friendlyScore)); + + const score = ((1.0 * genderScore) + (1.0 * statusScore) + (1.0 * adScore) + (1.0 * friendlyScore)); + + return (c.status === 'looking') ? score + 10.0 : score; } diff --git a/readme.md b/readme.md index 77ab7d5..d303b72 100644 --- a/readme.md +++ b/readme.md @@ -27,6 +27,10 @@ This repository contains a modified version of the mainline F-Chat 3.0 client. * Cleaner presentation for the side bar details (age, etc.), sorted in most relevant order * Less informative side bar details (views, contact) are separated and shown in a less prominent way * Cleaner guestbook view +* Character Search + * Display pairing score on search results + * Current search filters are listed on the search dialog + * Search filters can be reset ## Todo / Ideas