Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
57bb6e61
Commit
57bb6e61
authored
2 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
refactor(client): use setup syntax
parent
31d73f46
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/client/src/components/notification.vue
+69
-100
69 additions, 100 deletions
packages/client/src/components/notification.vue
with
69 additions
and
100 deletions
packages/client/src/components/notification.vue
+
69
−
100
View file @
57bb6e61
...
...
@@ -72,8 +72,8 @@
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
ref
,
onMounted
,
onUnmounted
,
watch
}
from
'
vue
'
;
<
script
lang=
"ts"
setup
>
import
{
ref
,
onMounted
,
onUnmounted
,
watch
}
from
'
vue
'
;
import
*
as
misskey
from
'
misskey-js
'
;
import
XReactionIcon
from
'
./reaction-icon.vue
'
;
import
MkFollowButton
from
'
./follow-button.vue
'
;
...
...
@@ -86,108 +86,77 @@ import * as os from '@/os';
import
{
stream
}
from
'
@/stream
'
;
import
{
useTooltip
}
from
'
@/scripts/use-tooltip
'
;
export
default
defineComponent
({
components
:
{
XReactionIcon
,
MkFollowButton
,
},
props
:
{
notification
:
{
type
:
Object
,
required
:
true
,
},
withTime
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
full
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
setup
(
props
)
{
const
elRef
=
ref
<
HTMLElement
>
(
null
);
const
reactionRef
=
ref
(
null
);
let
readObserver
:
IntersectionObserver
|
undefined
;
let
connection
;
onMounted
(()
=>
{
if
(
!
props
.
notification
.
isRead
)
{
readObserver
=
new
IntersectionObserver
((
entries
,
observer
)
=>
{
if
(
!
entries
.
some
(
entry
=>
entry
.
isIntersecting
))
return
;
stream
.
send
(
'
readNotification
'
,
{
id
:
props
.
notification
.
id
,
});
observer
.
disconnect
();
});
readObserver
.
observe
(
elRef
.
value
);
connection
=
stream
.
useChannel
(
'
main
'
);
connection
.
on
(
'
readAllNotifications
'
,
()
=>
readObserver
.
disconnect
());
watch
(
props
.
notification
.
isRead
,
()
=>
{
readObserver
.
disconnect
();
});
}
});
onUnmounted
(()
=>
{
if
(
readObserver
)
readObserver
.
disconnect
();
if
(
connection
)
connection
.
dispose
();
const
props
=
withDefaults
(
defineProps
<
{
notification
:
misskey
.
entities
.
Notification
;
withTime
?:
boolean
;
full
?:
boolean
;
}
>
(),
{
withTime
:
false
,
full
:
false
,
});
const
elRef
=
ref
<
HTMLElement
>
(
null
);
const
reactionRef
=
ref
(
null
);
let
readObserver
:
IntersectionObserver
|
undefined
;
let
connection
;
onMounted
(()
=>
{
if
(
!
props
.
notification
.
isRead
)
{
readObserver
=
new
IntersectionObserver
((
entries
,
observer
)
=>
{
if
(
!
entries
.
some
(
entry
=>
entry
.
isIntersecting
))
return
;
stream
.
send
(
'
readNotification
'
,
{
id
:
props
.
notification
.
id
,
});
observer
.
disconnect
();
});
const
followRequestDone
=
ref
(
false
);
const
groupInviteDone
=
ref
(
false
);
const
acceptFollowRequest
=
()
=>
{
followRequestDone
.
value
=
true
;
os
.
api
(
'
following/requests/accept
'
,
{
userId
:
props
.
notification
.
user
.
id
});
};
const
rejectFollowRequest
=
()
=>
{
followRequestDone
.
value
=
true
;
os
.
api
(
'
following/requests/reject
'
,
{
userId
:
props
.
notification
.
user
.
id
});
};
const
acceptGroupInvitation
=
()
=>
{
groupInviteDone
.
value
=
true
;
os
.
apiWithDialog
(
'
users/groups/invitations/accept
'
,
{
invitationId
:
props
.
notification
.
invitation
.
id
});
};
const
rejectGroupInvitation
=
()
=>
{
groupInviteDone
.
value
=
true
;
os
.
api
(
'
users/groups/invitations/reject
'
,
{
invitationId
:
props
.
notification
.
invitation
.
id
});
};
useTooltip
(
reactionRef
,
(
showing
)
=>
{
os
.
popup
(
XReactionTooltip
,
{
showing
,
reaction
:
props
.
notification
.
reaction
?
props
.
notification
.
reaction
.
replace
(
/^:
(\w
+
)
:$/
,
'
:$1@.:
'
)
:
props
.
notification
.
reaction
,
emojis
:
props
.
notification
.
note
.
emojis
,
targetElement
:
reactionRef
.
value
.
$el
,
},
{},
'
closed
'
);
readObserver
.
observe
(
elRef
.
value
);
connection
=
stream
.
useChannel
(
'
main
'
);
connection
.
on
(
'
readAllNotifications
'
,
()
=>
readObserver
.
disconnect
());
watch
(
props
.
notification
.
isRead
,
()
=>
{
readObserver
.
disconnect
();
});
}
});
onUnmounted
(()
=>
{
if
(
readObserver
)
readObserver
.
disconnect
();
if
(
connection
)
connection
.
dispose
();
});
return
{
getNoteSummary
:
(
note
:
misskey
.
entities
.
Note
)
=>
getNoteSummary
(
note
),
followRequestDone
,
groupInviteDone
,
notePage
,
userPage
,
acceptFollowRequest
,
rejectFollowRequest
,
acceptGroupInvitation
,
rejectGroupInvitation
,
elRef
,
reactionRef
,
i18n
,
};
},
const
followRequestDone
=
ref
(
false
);
const
groupInviteDone
=
ref
(
false
);
const
acceptFollowRequest
=
()
=>
{
followRequestDone
.
value
=
true
;
os
.
api
(
'
following/requests/accept
'
,
{
userId
:
props
.
notification
.
user
.
id
});
};
const
rejectFollowRequest
=
()
=>
{
followRequestDone
.
value
=
true
;
os
.
api
(
'
following/requests/reject
'
,
{
userId
:
props
.
notification
.
user
.
id
});
};
const
acceptGroupInvitation
=
()
=>
{
groupInviteDone
.
value
=
true
;
os
.
apiWithDialog
(
'
users/groups/invitations/accept
'
,
{
invitationId
:
props
.
notification
.
invitation
.
id
});
};
const
rejectGroupInvitation
=
()
=>
{
groupInviteDone
.
value
=
true
;
os
.
api
(
'
users/groups/invitations/reject
'
,
{
invitationId
:
props
.
notification
.
invitation
.
id
});
};
useTooltip
(
reactionRef
,
(
showing
)
=>
{
os
.
popup
(
XReactionTooltip
,
{
showing
,
reaction
:
props
.
notification
.
reaction
?
props
.
notification
.
reaction
.
replace
(
/^:
(\w
+
)
:$/
,
'
:$1@.:
'
)
:
props
.
notification
.
reaction
,
emojis
:
props
.
notification
.
note
.
emojis
,
targetElement
:
reactionRef
.
value
.
$el
,
},
{},
'
closed
'
);
});
</
script
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment