Skip to content

Commit

Permalink
Merge pull request #273 from LemmyNet/feature/bot_accounts
Browse files Browse the repository at this point in the history
Adding bot acct settings. Fixes #242
  • Loading branch information
dessalines authored Apr 24, 2021
2 parents e8a33d3 + affae3d commit 017121d
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lemmy-translations
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"eslint-plugin-prettier": "^3.3.1",
"husky": "^6.0.0",
"iso-639-1": "^2.1.9",
"lemmy-js-client": "0.11.0-rc.10",
"lemmy-js-client": "0.11.0-rc.11",
"lint-staged": "^10.5.4",
"mini-css-extract-plugin": "^1.4.1",
"node-fetch": "^2.6.1",
Expand Down
83 changes: 62 additions & 21 deletions src/shared/components/person.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,23 @@ export class Person extends Component<any, PersonState> {
{i18n.t("logout")}
</button>
) : (
<Link
className={"d-flex align-self-start btn btn-secondary"}
to={`/create_private_message/recipient/${pv.person.id}`}
>
{i18n.t("send_message")}
</Link>
<>
<a
className={`d-flex align-self-start btn btn-secondary mr-2 ${
!pv.person.matrix_user_id && "invisible"
}`}
rel="noopener"
href={`https://matrix.to/#/${pv.person.matrix_user_id}`}
>
{i18n.t("send_secure_message")}
</a>
<Link
className={"d-flex align-self-start btn btn-secondary"}
to={`/create_private_message/recipient/${pv.person.id}`}
>
{i18n.t("send_message")}
</Link>
</>
)}
</div>
{pv.person.bio && (
Expand Down Expand Up @@ -484,21 +495,6 @@ export class Person extends Component<any, PersonState> {
);
}

// TODO this isn't used currently
// matrixButton() {
// return (
// <a
// className={`d-flex align-self-start btn btn-secondary mr-2 ${
// !pv.local_user.matrix_user_id && "invisible"
// }`}
// rel="noopener"
// href={`https://matrix.to/#/${pv.local_user.matrix_user_id}`}
// >
// {i18n.t("send_secure_message")}
// </a>
// );
// }

userSettings() {
return (
<div>
Expand Down Expand Up @@ -797,6 +793,37 @@ export class Person extends Component<any, PersonState> {
</label>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input
class="form-check-input"
id="user-bot-account"
type="checkbox"
checked={this.state.saveUserSettingsForm.bot_account}
onChange={linkEvent(this, this.handleUserSettingsBotAccount)}
/>
<label class="form-check-label" htmlFor="user-bot-account">
{i18n.t("bot_account")}
</label>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input
class="form-check-input"
id="user-show-bot-accounts"
type="checkbox"
checked={this.state.saveUserSettingsForm.show_bot_accounts}
onChange={linkEvent(
this,
this.handleUserSettingsShowBotAccounts
)}
/>
<label class="form-check-label" htmlFor="user-show-bot-accounts">
{i18n.t("show_bot_accounts")}
</label>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input
Expand Down Expand Up @@ -970,6 +997,16 @@ export class Person extends Component<any, PersonState> {
i.setState(i.state);
}

handleUserSettingsBotAccount(i: Person, event: any) {
i.state.saveUserSettingsForm.bot_account = event.target.checked;
i.setState(i.state);
}

handleUserSettingsShowBotAccounts(i: Person, event: any) {
i.state.saveUserSettingsForm.show_bot_accounts = event.target.checked;
i.setState(i.state);
}

handleUserSettingsShowScoresChange(i: Person, event: any) {
i.state.saveUserSettingsForm.show_scores = event.target.checked;
UserService.Instance.localUserView.local_user.show_scores =
Expand Down Expand Up @@ -1148,6 +1185,10 @@ export class Person extends Component<any, PersonState> {
UserService.Instance.localUserView.person.display_name;
this.state.saveUserSettingsForm.show_avatars =
UserService.Instance.localUserView.local_user.show_avatars;
this.state.saveUserSettingsForm.bot_account =
UserService.Instance.localUserView.person.bot_account;
this.state.saveUserSettingsForm.show_bot_accounts =
UserService.Instance.localUserView.local_user.show_bot_accounts;
this.state.saveUserSettingsForm.show_scores =
UserService.Instance.localUserView.local_user.show_scores;
this.state.saveUserSettingsForm.email =
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5125,10 +5125,10 @@ lcid@^1.0.0:
dependencies:
invert-kv "^1.0.0"

lemmy-js-client@0.11.0-rc.10:
version "0.11.0-rc.10"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0-rc.10.tgz#304b5b941a00fe251fb50c81e5ae795e8bf0bd8d"
integrity sha512-bVLMnE1xm7mmmUC9gLIQ7wFNZn8HD3nmE56EhNGgqR76zdjZSSk+8ZqBYHUJ2yOikGebzIm0heMFryIsJuqwTg==
lemmy-js-client@0.11.0-rc.11:
version "0.11.0-rc.11"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0-rc.11.tgz#f99be613d08d0c196a16a37f74fdaa3b196f0459"
integrity sha512-IuNzU4+324fhb77JCQ/a/te/gXhQWUvxvtfV3xxQWJ0vG7kWOuz5Rd7KsfSF1d6LbuN9kbO9ebjSRW800ytbsA==

levn@^0.4.1:
version "0.4.1"
Expand Down

0 comments on commit 017121d

Please sign in to comment.