Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
Flutter App for Memri
Commits
5b6b1663
Commit
5b6b1663
authored
2 years ago
by
Koen van der Veen
Browse files
Options
Download
Email Patches
Plain Diff
make open window methods async for safari
parent
1de0e0aa
Pipeline
#10379
passed with stages
in 4 minutes and 12 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/providers/oauth_provider.dart
+23
-8
lib/providers/oauth_provider.dart
lib/widgets/importer/importer_connect_twitter.dart
+15
-2
lib/widgets/importer/importer_connect_twitter.dart
with
38 additions
and
10 deletions
+38
-10
lib/providers/oauth_provider.dart
+
23
-
8
View file @
5b6b1663
...
...
@@ -26,6 +26,8 @@ class OAuthProvider with ChangeNotifier {
final
GraphService
_graphService
;
final
GitlabService
_gitlabService
;
String
?
gitlabOauthUrl
;
OAuthProvider
(
this
.
_prefs
,
this
.
_podService
,
...
...
@@ -132,13 +134,16 @@ class OAuthProvider with ChangeNotifier {
_podService
.
createItem
(
item:
item
);
}
Future
<
void
>
openOAuthWindow
()
async
{
setGitlabOauthUrl
()
async
{
List
<
String
>
scopes
=
[
'api'
,
'read_repository'
,
'write_repository'
];
String
url
=
await
_podService
.
oauth2url
(
gitlabOauthUrl
=
await
_podService
.
oauth2url
(
_gitlabService
.
redirectUrl
,
scopes
,
'gitlab'
);
}
html
.
window
.
open
(
url
,
'_blank'
,
'location=yes, height=800,width=600'
);
openOAuthWindow
()
{
// safari only allows popup when a synchronous function is directly called on button click. Dont complicate this function
html
.
window
.
open
(
gitlabOauthUrl
!
,
'_blank'
,
'location=yes, height=800,width=600'
);
}
Future
<
Map
<
String
,
dynamic
>>
_requestOauthAccessToken
(
String
oauthVerifier
,
...
...
@@ -169,6 +174,7 @@ class OAuthProvider with ChangeNotifier {
}
Future
<
void
>
initGitlabOAuth
()
async
{
setGitlabOauthUrl
();
await
setGitlabAccesTokenFromPod
();
if
(
_gitlabService
.
gitlabAccessToken
==
null
)
{
// start a listener for accessToken, if it finds one, set in the gitlab api and test auth
...
...
@@ -212,16 +218,25 @@ class OAuthProvider with ChangeNotifier {
}
/// Twitter
///
Future
<
void
>
initTwitterOAuth
(
BuildContext
context
)
async
{
String
?
twitterOauthToken
;
String
?
twitterOauthTokenSecret
;
setTwitterOauthToken
()
async
{
String
redirectUrl
=
'
${_gitlabService.endpoint}
/oauth?state=twitter'
;
var
res
=
await
_oAuthService
.
oauthRequestToken
(
'twitter'
,
redirectUrl
);
twitterOauthToken
=
res
[
'oauth_token'
];
twitterOauthTokenSecret
=
res
[
'oauth_token_secret'
];
}
void
initTwitterOAuth
(
BuildContext
context
)
{
_setOAuthCompleted
(
false
);
var
res
=
await
_oAuthService
.
oauthRequestToken
(
'twitter'
,
redirectUrl
);
final
queryParameters
=
{
'oauth_token'
:
res
[
'oauth_token'
]};
final
queryParameters
=
{
'oauth_token'
:
twitterOauthToken
!
};
// we are using this in the redirect screen
_prefs
.
setString
(
'oauthTokenSecret'
,
res
[
'o
auth
_t
oken
_s
ecret
'
]
);
_prefs
.
setString
(
'oauthTokenSecret'
,
twitterO
auth
T
oken
S
ecret
!
);
var
url
=
Uri
.
https
(
'api.twitter.com'
,
'/oauth/authorize'
,
queryParameters
);
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/importer/importer_connect_twitter.dart
+
15
-
2
View file @
5b6b1663
...
...
@@ -5,12 +5,24 @@ import 'package:memri/utilities/helpers/responsive_helper.dart';
import
'package:memri/widgets/screen_error.dart'
;
import
'package:provider/provider.dart'
;
class
ImporterConnectTwitter
extends
State
less
Widget
{
class
ImporterConnectTwitter
extends
State
ful
Widget
{
const
ImporterConnectTwitter
({
Key
?
key
,
required
this
.
parentContext
})
:
super
(
key:
key
);
final
BuildContext
parentContext
;
@override
State
<
ImporterConnectTwitter
>
createState
()
=
>
_ImporterConnectTwitterState
();
}
class
_ImporterConnectTwitterState
extends
State
<
ImporterConnectTwitter
>
{
@override
initState
()
{
var
provider
=
Provider
.
of
<
OAuthProvider
>(
context
,
listen:
false
);
provider
.
setTwitterOauthToken
();
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer
<
OAuthProvider
>(
builder:
(
context
,
provider
,
_
)
{
...
...
@@ -38,7 +50,8 @@ class ImporterConnectTwitter extends StatelessWidget {
),
SizedBox
(
height:
30
),
TextButton
(
onPressed:
()
=
>
provider
.
initTwitterOAuth
(
parentContext
),
onPressed:
()
=
>
provider
.
initTwitterOAuth
(
widget
.
parentContext
),
child:
Text
(
'Authorise Twitter'
,
style:
AppStyles
.
buttonLabel
),
style:
tertiaryButtonStyle
),
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets