Skip to content

Commit

Permalink
add mw.Rest object, talk page redirect defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Jul 13, 2022
1 parent a7cc696 commit 525b181
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Deputy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Deputy {
currentPageId = mw.config.get( 'wgArticleId' );

wiki: mw.Api;
wikiRest: mw.Rest;
api: DeputyAPI;
storage: DeputyStorage;
prefs: DeputyPreferences;
Expand Down Expand Up @@ -101,6 +102,7 @@ class Deputy {
errorsuselocal: true
}
} );
this.wikiRest = new mw.Rest();

// Inject CSS
mw.util.addCSS( deputyStyles );
Expand Down
18 changes: 9 additions & 9 deletions src/wiki/TalkPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default class TalkPage {
await window.deputy.wiki.postWithEditToken(
Object.assign( {
// Overridable options.
redirect: true
redirect: this.talkPage.getNamespaceId() !==
mw.config.get( 'wgNamespaceIds' ).user_talk
}, editOptions, {
// Non-overridable options
action: 'edit',
Expand All @@ -78,18 +79,17 @@ export default class TalkPage {
options: TalkPageEditOptions = {},
editOptions: Record<string, any> = {}
): Promise<void> {
await window.deputy.wiki.postWithEditToken(
await window.deputy.wiki.newSection(
this.talkPage,
sectionTitle,
message,
Object.assign( {
// Overridable options.
redirect: true
redirect: this.talkPage.getNamespaceId() !==
mw.config.get( 'wgNamespaceIds' ).user_talk
}, editOptions, {
// Non-overridable options
action: 'edit',
title: this.talkPage.getPrefixedText(),
summary: decorateEditSummary( options.summary ),
section: 'new',
sectiontitle: sectionTitle,
text: message
summary: decorateEditSummary( options.summary )
} )
);
}
Expand Down

0 comments on commit 525b181

Please sign in to comment.