Skip to content

Commit

Permalink
Merge branch 'release/v3.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kitce committed Apr 4, 2022
2 parents 156864a + 0738e50 commit 65e7086
Show file tree
Hide file tree
Showing 19 changed files with 338 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .cz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ commitizen:
changelog_start_rev: v2.0.0
name: cz_conventional_commits
tag_format: v$version
version: 3.4.0
version: 3.4.1
version_files:
- package.json
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## v3.4.1 (2022-04-05)

### Fix

- **merge**: add `mergeConfig`
- **schemas**: missing `subscriptionTemplates` in `config` schema
- **mutation**: issue of not showing labels or showing the labels on incorrect user in reply modal
- **mutation**: cannot display labels on replies after any blocked user's reply (#8)
- **label-form**: cannot enable auto screenshot (#10)

### Refactor

- **mutation**: unmount the component before removing the container from DOM
- **helpers**: update `getAvailableLabelID` to `getNextLabelID`
- **helpers**: update `getShareURL`

## v3.4.0 (2022-04-04)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion dist/egg.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/libel.meta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Libel
// @version 3.4.0
// @version 3.4.1
// @author kitce <[email protected]>
// @description Label users on LIHKG
// @homepage https://kitce.github.io/libel
Expand Down
4 changes: 2 additions & 2 deletions dist/libel.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "libel",
"namespace": "libel",
"displayName": "Libel",
"version": "3.4.0",
"version": "3.4.1",
"description": "Label users on LIHKG",
"author": "kitce <[email protected]>",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/LabelForm/LabelForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const LabelForm: React.FunctionComponent<TProps> = (props) => {
fullWidth
checked={toggleButtonState.useScreenshot}
disabled={loading}
name="useReplyScreenshot"
name="useScreenshot"
loading={screenshot.loading}
onChange={handleToggleButtonChange}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EventAction } from '../../../constants/ga';
import * as TEXTS from '../../../constants/texts';
import { download, _export, _import } from '../../../helpers/file';
import * as gtag from '../../../helpers/gtag';
import { mergeDataSet, mergeSubscriptions } from '../../../helpers/merge';
import { mergeConfig, mergeDataSet, mergeSubscriptions } from '../../../helpers/merge';
import Personal from '../../../models/Personal';
import type { ISerializedStorage } from '../../../models/Storage';
import { selectConfig, selectPersonal, selectSubscriptions } from '../../../store/selectors';
Expand Down Expand Up @@ -114,7 +114,7 @@ const ManageDataSection: React.FunctionComponent = () => {
try {
const incoming = await _import(file);
const storage: ISerializedStorage = {
config: { ...config, ...incoming.config },
config: mergeConfig(config, incoming.config, false),
// CAVEAT: ignore `meta` here
personal: mergeDataSet(personal.plain(), incoming.personal, false),
subscriptions: mergeSubscriptions(subscriptions, incoming.subscriptions, false)
Expand Down
10 changes: 5 additions & 5 deletions src/helpers/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { selectConfig, selectMeta, selectPersonal, selectSubscriptions } from '.
import { loadDataIntoStore } from './../store/store';
import { compress, decompress } from './file';
import * as gapi from './gapi';
import { MergeDirection, mergeDataSet, mergeSubscriptions } from './merge';
import { mergeConfig, mergeDataSet, MergeDirection, mergeSubscriptions } from './merge';

const debug = debugFactory('libel:helper:cloud');

Expand Down Expand Up @@ -69,13 +69,13 @@ export const sync = async () => {
// merge with local data
const mergeDirection = ((lastSyncedTime === modifiedTime) && (lastModifiedTime > modifiedTime)) ? MergeDirection.LocalToIncoming : MergeDirection.IncomingToLocal;
debug('sync:mergeDirection', MergeDirection[mergeDirection]);
const [[personalA, personalB], [subscriptionsA, subscriptionsB]] = (
const [[configA, configB], [personalA, personalB], [subscriptionsA, subscriptionsB]] = (
mergeDirection === MergeDirection.LocalToIncoming ?
[[remoteStorage.personal, personal.plain()], [remoteStorage.subscriptions, subscriptions]] :
[[personal.plain(), remoteStorage.personal], [subscriptions, remoteStorage.subscriptions]]
[[remoteStorage.config, config], [remoteStorage.personal, personal.plain()], [remoteStorage.subscriptions, subscriptions]] :
[[config, remoteStorage.config], [personal.plain(), remoteStorage.personal], [subscriptions, remoteStorage.subscriptions]]
);
const storage: ISerializedStorage = {
config: { ...config, ...remoteStorage.config },
config: mergeConfig(configA, configB, true),
// CAVEAT: ignore `meta` here
personal: mergeDataSet(personalA, personalB, true),
subscriptions: mergeSubscriptions(subscriptionsA, subscriptionsB, true)
Expand Down
1 change: 1 addition & 0 deletions src/helpers/dataSetEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { mapValidationError } from './validation';
* labels group item
* @typedef {ILabel} origianl the original object that will not be updated
* @typedef {ILabel} draft the draft object that will be updated
* @typedef {boolean} removed indicate whether the item will be removed
*/
export type ILabelsGroupItem = [original: ILabel, draft: ILabel, removed: boolean];

Expand Down
21 changes: 10 additions & 11 deletions src/helpers/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { displayDateFormat } from '../constants/label';
import { shortenedHost } from '../constants/lihkg';
import type { IPost } from '../types/lihkg';
import type { ILabel, ISource } from './../models/Label';
import type { TTracablePost } from './../types/lihkg';
import { counter } from './counter';
import { getShareID } from './lihkg';

Expand All @@ -15,16 +14,17 @@ export const mapPostToSource = (post: IPost): ISource => {
};
};

export const mapSourceToPost = (source: ISource): TTracablePost => {
return {
thread_id: source.thread,
page: source.page,
msg_num: source.messageNumber
};
const getLastID = (labels: ILabel[]) => {
const _labels = labels.filter((label) => !!label.id);
_labels.sort((a, b) => parseInt(b.id!) - parseInt(a.id!));
const last = _labels[0];
return last ? last.id! : '0';
};

export const getAvailableLabelID = (labels: ILabel[]) => {
const count = counter(1);
export const getNextLabelID = (labels: ILabel[]) => {
const lastID = getLastID(labels);
const initial = parseInt(lastID) + 1;
const count = counter(initial);
while (true) {
const { value } = count.next();
const id = `${value}`;
Expand All @@ -38,8 +38,7 @@ export const getAvailableLabelID = (labels: ILabel[]) => {
export const getShareURL = (label: ILabel) => {
const { source } = label;
if (source) {
const post = mapSourceToPost(source);
const shareID = getShareID(post);
const shareID = getShareID(source);
return `${shortenedHost}/${shareID}`;
}
// fallback to the deprecated url
Expand Down
13 changes: 7 additions & 6 deletions src/helpers/lihkg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// import debugFactory from 'debug';
import produce from 'immer';
import { ISource } from '../models/Label';
import lihkgSelectors from '../stylesheets/variables/lihkg/selectors.module.scss';
import type { IIconMap, IUser, TTracablePost } from '../types/lihkg';
import type { IIconMap, IUser } from '../types/lihkg';
import { waitForElement } from './dom';
import { findReduxStore, IReactRootElement } from './redux';

Expand Down Expand Up @@ -53,16 +54,16 @@ export const unlockIconMap = (iconMap: IIconMap) => {
/**
* get the share ID of the reply
* @copyright the implementation is a reference from LIHKG production build
* @param {TTracablePost} post the label source
* @param {ISource} source the label source
* @returns the share ID
*/
export const getShareID = (post: TTracablePost) => {
const e = post.thread_id; // thread ID
if (post.msg_num === '1') {
export const getShareID = (source: ISource) => {
const e = source.thread; // thread ID
if (source.messageNumber === '1') {
return e;
}
const t = ShareType.Reply; // the share type: thread or reply
const n = parseInt(post.msg_num, 10); // the share variable: message number
const n = parseInt(source.messageNumber, 10); // the share variable: message number
const x = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQR'; // the hash seed
const C = (e: number, t: string) => {
let n;
Expand Down
Loading

0 comments on commit 65e7086

Please sign in to comment.