From e546972af1f159918a9bf9e3ec89126646be90e0 Mon Sep 17 00:00:00 2001 From: "Mr. Stallion" Date: Mon, 8 Jul 2019 18:27:14 -0500 Subject: [PATCH] Ads view --- chat/AdView.vue | 72 +++++++++++++++++++++++++++++++++++++++ chat/ConversationView.vue | 56 +++++++++++++++++++++++++++++- chat/ImagePreview.vue | 2 +- chat/message_view.ts | 20 ++--------- electron/Index.vue | 3 ++ learn/ad-cache.ts | 3 +- learn/profile-cache.ts | 24 ++++++++++++- 7 files changed, 158 insertions(+), 22 deletions(-) create mode 100644 chat/AdView.vue diff --git a/chat/AdView.vue b/chat/AdView.vue new file mode 100644 index 0000000..6a92130 --- /dev/null +++ b/chat/AdView.vue @@ -0,0 +1,72 @@ + + + + diff --git a/chat/ConversationView.vue b/chat/ConversationView.vue index 46ffa67..31dce47 100644 --- a/chat/ConversationView.vue +++ b/chat/ConversationView.vue @@ -13,6 +13,10 @@ {{l('chat.report')}} + + + Ads +
{{l('status.' + conversation.character.status)}} @@ -136,6 +140,7 @@ +
@@ -145,6 +150,7 @@ import {EditorButton, EditorSelection} from '../bbcode/editor'; import {isShowing as anyDialogsShown} from '../components/Modal.vue'; import {Keys} from '../keys'; + import AdView from './AdView.vue'; import {BBCodeView, Editor} from './bbcode'; import CommandHelp from './CommandHelp.vue'; import { characterImage, getByteLength, getKey } from './common'; @@ -162,7 +168,8 @@ @Component({ components: { user: UserView, 'bbcode-editor': Editor, 'manage-channel': ManageChannel, settings: ConversationSettings, - logs: Logs, 'message-view': MessageView, bbcode: BBCodeView, 'command-help': CommandHelp + logs: Logs, 'message-view': MessageView, bbcode: BBCodeView, 'command-help': CommandHelp, + 'ad-view': AdView } }) export default class ConversationView extends Vue { @@ -400,6 +407,10 @@ (this.$refs['manageDialog']).show(); } + showAds(): void { + (this.$refs['adViewer']).show(); + } + isAutopostingAds(): boolean { return this.conversation.adManager.isActive(); @@ -593,7 +604,36 @@ } } + .message-time, + .message .message-time, + .ad-viewer .message-time { + background-color: #4f4f61; + color: #dadada; + border-radius: 3px; + padding-left: 3px; + padding-right: 3px; + padding-bottom: 2px; + padding-top: 1px; + margin-right: 3px; + font-size: 80%; + } + .ad-viewer { + display: block; + + h3 { + font-size: 12pt; + + .message-time { + padding-bottom: 1px; + } + } + + .border-bottom { + margin-bottom: 15px; + border-width: 1px; + } + } .message { &.message-event { @@ -615,6 +655,20 @@ background-color: rgba(0, 58, 0, 0.35); } + &.neutral { + border-left: 12px solid #555; + + .bbcode { + filter: grayscale(0.5); + } + + .bbcode, + .user-view, + .message-time { + opacity: 0.6; + } + }; + &.weak-mismatch { background-color: rgba(208, 188, 0, 0.0); border-left: 12px solid rgb(138, 123, 0); diff --git a/chat/ImagePreview.vue b/chat/ImagePreview.vue index 57ffef9..06bcbca 100644 --- a/chat/ImagePreview.vue +++ b/chat/ImagePreview.vue @@ -40,7 +40,7 @@ @Component export default class ImagePreview extends Vue { - private readonly MinTimePreviewVisible = 500; + private readonly MinTimePreviewVisible = 100; visible = false; diff --git a/chat/message_view.ts b/chat/message_view.ts index 69212b0..6bfee6b 100644 --- a/chat/message_view.ts +++ b/chat/message_view.ts @@ -26,7 +26,7 @@ const userPostfix: {[key: number]: string | undefined} = { // ); const children: VNodeChildrenArrayContents = - [createElement('span', {staticClass: 'message-time'}, `[${formatTime(message.time)}] `)]; + [createElement('span', {staticClass: 'message-time'}, `${formatTime(message.time)}`)]; const separators = core.connection.isOpen ? core.state.settings.messageSeparators : false; /*tslint:disable-next-line:prefer-template*///unreasonable here let classes = `message message-${Conversation.Message.Type[message.type].toLowerCase()}` + (separators ? ' message-block' : '') + @@ -104,27 +104,11 @@ export default class MessageView extends Vue { } getMessageScoreClasses(message: Conversation.Message): string { - if (message.score === 0) { + if (message.type !== Conversation.Message.Type.Ad) { return ''; } - // console.log('Score was', message.score); - return `message-score ${Score.getClasses(message.score as Scoring)}`; - - // const baseClass = message.score > 0 ? 'message-score-positive' : 'message-score-negative'; - // - // const score = Math.abs(message.score); - // - // let scoreStrength = 'message-score-normal'; - // - // if (score > 3) { - // scoreStrength = 'message-score-high'; - // } else if (score > 1.5) { - // scoreStrength = 'message-score-medium'; - // } - // - // return `message-score ${baseClass} ${scoreStrength}`; } } \ No newline at end of file diff --git a/electron/Index.vue b/electron/Index.vue index 838bd61..fc201db 100644 --- a/electron/Index.vue +++ b/electron/Index.vue @@ -128,6 +128,7 @@ settings!: GeneralSettings; importProgress = 0; profileName = ''; + adName = ''; fixCharacters: ReadonlyArray = []; fixCharacter = ''; @@ -141,11 +142,13 @@ electron.ipcRenderer.on('settings', (_: Event, settings: GeneralSettings) => core.state.generalSettings = this.settings = settings); + electron.ipcRenderer.on('open-profile', (_: Event, name: string) => { const profileViewer = this.$refs['profileViewer']; this.profileName = name; profileViewer.show(); }); + electron.ipcRenderer.on('fix-logs', async() => { this.fixCharacters = await new SettingsStore().getAvailableCharacters(); this.fixCharacter = this.fixCharacters[0]; diff --git a/learn/ad-cache.ts b/learn/ad-cache.ts index fe9fc73..f4bacbb 100644 --- a/learn/ad-cache.ts +++ b/learn/ad-cache.ts @@ -12,7 +12,8 @@ export interface AdPosting extends AdCachedPosting { export class AdCacheRecord { protected name: string; - protected posts: AdCachedPosting[] = []; + + readonly posts: AdCachedPosting[] = []; constructor(name: string, posting?: AdPosting) { this.name = name; diff --git a/learn/profile-cache.ts b/learn/profile-cache.ts index eb33a85..0c3681e 100644 --- a/learn/profile-cache.ts +++ b/learn/profile-cache.ts @@ -126,8 +126,11 @@ export class ProfileCache extends AsyncCache { // const score = Math.min(m.them.total, m.you.total); // mul * (Math.abs(m.you.total) + Math.abs(m.them.total)); + const yourScores = _.values(m.you.scores); + const theirScores = _.values(m.them.scores); + const finalScore = _.reduce( - _.concat(_.values(m.them.scores), _.values(m.you.scores)), + _.concat(yourScores, theirScores), (accum: Scoring | null, score: Score) => { if (accum === null) { return (score.score !== Scoring.NEUTRAL) ? score.score : null; @@ -138,6 +141,25 @@ export class ProfileCache extends AsyncCache { null ); + + if ((finalScore !== null) && (finalScore > 0)) { + // Manage edge cases where high score may not be ideal + + // Nothing to score + if ((yourScores.length === 0) || (theirScores.length === 0)) { + // can't know + return Scoring.NEUTRAL; + } + + // Only neutral scores given + if ( + (_.every(yourScores, (n: Scoring) => n === Scoring.NEUTRAL)) || + (_.every(theirScores, (n: Scoring) => n === Scoring.NEUTRAL)) + ) { + return Scoring.NEUTRAL; + } + } + // console.log('Profile score', c.character.name, score, m.you.total, m.them.total, // m.you.total + m.them.total, m.you.total * m.them.total);