Skip to content

Commit ae9c33c

Browse files
authored
fix: remove the option to flag as VLQ
1 parent 4a0e5ad commit ae9c33c

7 files changed

Lines changed: 20 additions & 48 deletions

File tree

src/AdvancedFlagging.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import Post from './UserscriptTools/Post';
22
import Page from './UserscriptTools/Page';
33

4-
import { Flags } from './FlagTypes';
54
import { setupConfiguration } from './Configuration';
65
import { Popover } from './popover';
76

87
import { setupReview } from './review';
9-
import { addXHRListener, FlagNames, interceptXhr, popupDelay } from './shared';
8+
import { addXHRListener, interceptXhr, popupDelay } from './shared';
109

1110
import { NattyAPI } from './UserscriptTools/NattyApi';
1211
import { MetaSmokeAPI } from './UserscriptTools/MetaSmokeAPI';
@@ -72,20 +71,6 @@ popupWrapper.id = 'advanced-flagging-snackbar';
7271

7372
document.body.append(popupWrapper);
7473

75-
export function getFlagToRaise(
76-
flagName: Flags,
77-
qualifiesForVlq: boolean
78-
): Flags {
79-
const vlqFlag = FlagNames.VLQ;
80-
const naaFlag = FlagNames.NAA;
81-
82-
// If the flag name is VLQ, check if the criteria are met.
83-
// If not, switch to NAA
84-
return flagName === vlqFlag
85-
? (qualifiesForVlq ? vlqFlag : naaFlag)
86-
: flagName;
87-
}
88-
8974
export function displayToaster(
9075
text: string,
9176
state: 'success' | 'danger'

src/Configuration.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ function setupDefaults(): void {
132132

133133
Store.updateConfiguration();
134134
}
135+
136+
// https://meta.stackoverflow.com/a/434697
137+
Store.flagTypes
138+
// @ts-expect-error VLQ flag is removed, see the link above
139+
.filter(({ reportType }) => reportType === 'PostLowQuality')
140+
.forEach(flagType => {
141+
flagType.reportType = FlagNames.NAA;
142+
});
143+
144+
Store.updateFlagTypes();
135145
}
136146

137147
export function setupConfiguration(): void {

src/FlagTypes.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export type Flags = 'AnswerNotAnAnswer'
66
| 'PostSpam'
77
| 'NoFlag'
88
| 'PostOther'
9-
| 'PostLowQuality'
109
| 'PlagiarizedContent';
1110

1211
const deletedAnswers = '/help/deleted-answers';
@@ -111,7 +110,7 @@ export const flagCategories: FlagCategory[] = [
111110
{
112111
id: 6,
113112
displayName: 'Link Only',
114-
reportType: FlagNames.VLQ,
113+
reportType: FlagNames.NAA,
115114
comments: {
116115
// comment by Yunnosch: https://chat.stackoverflow.com/transcript/message/57442309
117116
low: 'A link to a solution is welcome, but please ensure your answer is useful without it: '
@@ -179,7 +178,7 @@ export const flagCategories: FlagCategory[] = [
179178
{
180179
id: 10,
181180
displayName: 'Library',
182-
reportType: FlagNames.VLQ,
181+
reportType: FlagNames.NAA,
183182
comments: {
184183
low: 'Please don\'t just post some tool or library as an answer. At least demonstrate '
185184
+ '[how it solves the problem](//meta.stackoverflow.com/a/251605) in the answer itself.',
@@ -214,7 +213,7 @@ export const flagCategories: FlagCategory[] = [
214213
{
215214
id: 13,
216215
displayName: 'Non English',
217-
reportType: FlagNames.VLQ,
216+
reportType: FlagNames.NAA,
218217
comments: {
219218
low: 'Please write your answer in English, as Stack Overflow is an '
220219
+ '[English-only site](//meta.stackoverflow.com/a/297680).',

src/UserscriptTools/NattyApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class NattyAPI extends Reporter {
114114
if (!this.canBeReported()) return '';
115115

116116
// Handle cases where the post may not be reported to Natty on time:
117-
// - when a mod flags a post as NAA/VLQ it is deleted immediately.
117+
// - when a mod flags a post as NAA it is deleted immediately.
118118
// - when a reviewer sends the last Recommend deletion/Delete review,
119119
// the post is also deleted immediately
120120
// - if a red flag has been raised by the user

src/UserscriptTools/Post.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getFlagToRaise, page } from '../AdvancedFlagging';
1+
import { page } from '../AdvancedFlagging';
22
import { Flags } from '../FlagTypes';
33
import {
44
PostType,
@@ -110,12 +110,9 @@ export default class Post {
110110
}
111111

112112
public async flag(
113-
reportType: Flags,
113+
flagName: Flags,
114114
text: string | null,
115115
): Promise<void> {
116-
// if the flag name is VLQ, then we need to check if the criteria are met.
117-
// If not, switch to NAA
118-
const flagName = getFlagToRaise(reportType, this.qualifiesForVlq());
119116
const targetUrl = this.reporters.Guttenberg?.targetUrl;
120117

121118
const url = `/flags/posts/${this.id}/add/${flagName}`;
@@ -427,14 +424,6 @@ export default class Post {
427424
);
428425
}
429426

430-
public qualifiesForVlq(): boolean {
431-
const dayMillis = 1000 * 60 * 60 * 24;
432-
433-
// a post can't be flagged as VLQ if it has a positive score
434-
// or is more than 1 day old
435-
return (new Date().valueOf() - this.date.valueOf()) < dayMillis && this.score <= 0;
436-
}
437-
438427
// returns [bot name, checkbox config]
439428
public getFeedbackBoxes(isFlagOrReview = false): ReporterBoxes {
440429
type ReportersEntries = [

src/popover.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
delay,
1111
configBoxes
1212
} from './shared';
13-
import { getFlagToRaise } from './AdvancedFlagging';
1413
import Post from './UserscriptTools/Post';
1514

1615
import { Menu, Spinner } from '@userscripters/stacks-helpers';
@@ -209,7 +208,7 @@ export class Popover {
209208
): string {
210209
/*
211210
Example innerText:
212-
Flag: as VLQ
211+
Flag: as NAA
213212
Comment: Please write your answer in English, as Stack Overflow
214213
is an [English-only site](//meta.stackoverflow.com/a/297680).
215214
Feedbacks: tp to Natty, track with Generic Bot
@@ -235,17 +234,10 @@ export class Popover {
235234
const commentText = this.getCommentText(flagType);
236235
const tooltipCommentText = (this.post.deleted ? '' : commentText) || '';
237236

238-
// if the flag changed from VLQ to NAA, let the user know why
239-
const flagName = getFlagToRaise(reportType, this.post.qualifiesForVlq());
240-
241-
let reportTypeHuman = reportType === 'NoFlag' || !this.post.deleted
242-
? getHumanFromDisplayName(flagName)
237+
const reportTypeHuman = reportType === 'NoFlag' || !this.post.deleted
238+
? getHumanFromDisplayName(reportType)
243239
: '';
244240

245-
if (reportType !== flagName) {
246-
reportTypeHuman += ' (VLQ criteria aren\'t met)';
247-
}
248-
249241
// ---------------------------------------------------
250242

251243
const popoverParent = document.createElement('div');

src/shared.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export enum FlagNames {
3636
Spam = 'PostSpam',
3737
Rude = 'PostOffensive',
3838
NAA = 'AnswerNotAnAnswer',
39-
VLQ = 'PostLowQuality',
4039
NoFlag = 'NoFlag',
4140
Plagiarism = 'PlagiarizedContent',
4241
ModFlag = 'PostOther'
@@ -167,7 +166,6 @@ export type HumanFlags = 'as NAA'
167166
| 'as R/A'
168167
| 'as spam'
169168
| 'for plagiarism'
170-
| 'as VLQ'
171169
| 'for moderator attention'
172170
| '';
173171

@@ -176,7 +174,6 @@ export function getHumanFromDisplayName(displayName: Flags): HumanFlags {
176174
[FlagNames.Spam]: 'as spam',
177175
[FlagNames.Rude]: 'as R/A',
178176
[FlagNames.NAA]: 'as NAA',
179-
[FlagNames.VLQ]: 'as VLQ',
180177
[FlagNames.NoFlag]: '',
181178
[FlagNames.Plagiarism]: 'for plagiarism',
182179
[FlagNames.ModFlag]: 'for moderator attention',

0 commit comments

Comments
 (0)