Skip to content

Commit

Permalink
Merge pull request #1501 from cayb0rg/issue/null-check
Browse files Browse the repository at this point in the history
Quick misc fixes
  • Loading branch information
clpetersonucf authored Oct 17, 2023
2 parents 16c3c3c + f473fe2 commit 44152c3
Show file tree
Hide file tree
Showing 20 changed files with 149 additions and 122 deletions.
4 changes: 2 additions & 2 deletions fuel/app/classes/controller/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,12 @@ protected function build_widget_login_messages($inst)
{
// $start_string = '<span class="available_date">'.date($format, (int) $inst->open_at).'</span>';
$start_string = date($format, (int) $inst->open_at);
$start_sec = date('h:i A', (int) $inst->open_at * 1000);
$start_sec = date('h:i A', (int) $inst->open_at);
}
if ($status['closes'])
{
$end_string = date($format, (int) $inst->close_at);
$end_sec = date('h:i A', (int) $inst->close_at * 1000);
$end_sec = date('h:i A', (int) $inst->close_at);
}

// finish the actual messages to the user
Expand Down
2 changes: 1 addition & 1 deletion fuel/app/classes/materia/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function safeTrim($value)
return is_string($value) ? trim($value) : $value;
}

public static function get_avatar($size=35, $user=false)
public static function get_avatar($size=128, $user=false)
{
$default = \Config::get('materia.urls.static').'/img/default-avatar.jpg';
if ( ! $user) $user = \Model_User::find_current();
Expand Down
4 changes: 2 additions & 2 deletions fuel/app/classes/model/notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function send_item_notification(int $from_user_id, int $to_user_id
break;

case 'access_request':
$subject = "$user_link is requesting access to your widget \"$widget_name\".<br /> The widget is currently being used within a course in your LMS.";
$subject = "$user_link is requesting access to your widget \"$widget_link\".<br /> The widget is currently being used within a course in your LMS.";
$action = 'access_request';
break;

Expand All @@ -133,7 +133,7 @@ public static function send_item_notification(int $from_user_id, int $to_user_id
'is_email_sent' => ($send_email ? '0' : '1'),
'is_read' => '0',
'subject' => $subject,
'avatar' => \Materia\Utils::get_avatar(50),
'avatar' => \Materia\Utils::get_avatar(128),
'action' => $action,
'created_at' => time()
]);
Expand Down
2 changes: 1 addition & 1 deletion fuel/app/classes/model/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static protected function forge_guest()

public function to_array($custom = false, $recurse = false, $eav = false)
{
$avatar = \Materia\Utils::get_avatar(50, $this);
$avatar = \Materia\Utils::get_avatar(256, $this);
$array = parent::to_array($custom, $recurse, $eav);
$array['avatar'] = $avatar;
$array['is_student'] = \Materia\Perm_Manager::is_student($this->id);
Expand Down
2 changes: 1 addition & 1 deletion src/components/extra-attempts-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const ExtraAttemptsDialog = ({onClose, inst}) => {
state.newIdCount,
{
id: parseInt(state.newIdCount),
context_id: '',
context_id: "",
extra_attempts: 1,
user_id: parseInt(match.id)
}
Expand Down
1 change: 1 addition & 0 deletions src/components/extra-attempts-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
height: 40px;
width: 40px;
margin-right: 10px;
border-radius: 5px;
}

.user_name {
Expand Down
2 changes: 1 addition & 1 deletion src/components/hooks/useSupportDeleteWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function useSupportDeleteWidget() {
apiDeleteWidget,
{
onSuccess: (data, variables) => {
if (data !== null) {
if (!!data) {
variables.successFunc()
queryClient.invalidateQueries('widgets')
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/hooks/useSupportUnDeleteWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function useSupportUnDeleteWidget() {
apiUnDeleteWidget,
{
onSuccess: (data, variables) => {
if (data !== null) {
if (!!data) {
variables.successFunc()
queryClient.removeQueries('search-widgets', {
exact: false
Expand Down
2 changes: 1 addition & 1 deletion src/components/include.scss
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ header {

.subject {
line-height: 1.5em;

a {
font-weight: bold;
text-decoration: underline;
Expand Down
6 changes: 4 additions & 2 deletions src/components/my-widgets-collaborate-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ const MyWidgetsCollaborateDialog = ({onClose, inst, myPerms, otherUserPerms, set
placeholderData: [],
retry: false,
onSuccess: (data) => {
if (!data || (data.type == 'error'))
if (data && data.type == 'error')
{
console.error(`User search failed with error: ${data.msg}`);
if (data.title =="Invalid Login")
if (data.title == "Invalid Login")
{
setInvalidLogin(true)
}
} else if (!data) {
console.error(`User search failed.`);
}
}
})
Expand Down
1 change: 1 addition & 0 deletions src/components/my-widgets-collaborate-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
height: 50px;
width: 50px;
margin-right: 10px;
border-radius: 5px;
}
.name {
display: inline-block;
Expand Down
10 changes: 6 additions & 4 deletions src/components/my-widgets-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const MyWidgetsPage = () => {
widgetName: inst.widget.name,
dir: inst.widget.dir,
successFunc: (data) => {
if (!data || (data.type == 'error'))
if (data && (data.type == 'error'))
{
console.error(`Failed to copy widget with error: ${data.msg}`);
if (data.title == "Invalid Login")
Expand Down Expand Up @@ -245,13 +245,15 @@ const MyWidgetsPage = () => {
{
instId: inst.id,
successFunc: (data) => {
if (!data || (data.type == 'error'))
if (data && data.type == 'error')
{
console.error(`Deletion failed with error: ${data.msg}`);
if (data.title =="Invalid Login")
console.error(`Error: ${data.msg}`);
if (data.title == "Invalid Login")
{
setInvalidLogin(true)
}
} else if (!data) {
console.error(`Delete widget failed.`);
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions src/components/my-widgets-selected-instance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ const MyWidgetSelectedInstance = ({
enabled: !!inst.id,
staleTime: Infinity,
onSuccess: (data) => {
if (!data || data.type == 'error')
if (data && data.type == 'error')
{
console.error(`Error: ${data.msg}`);
if (data.title =="Invalid Login")
if (data.title == "Invalid Login")
{
setInvalidLogin(true)
}
} else if (!data) {
console.error(`Failed to fetch permissions.`);
}
}
})
Expand Down
6 changes: 4 additions & 2 deletions src/components/my-widgets-settings-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ const MyWidgetsSettingsDialog = ({ onClose, inst, currentUser, otherUserPerms, o
enabled: !!otherUserPerms && Array.from(otherUserPerms.keys())?.length > 0,
staleTime: Infinity,
onSuccess: (data) => {
if (!data || (data.type == 'error'))
if (data && data.type == 'error')
{
console.error(`Error: ${data.msg}`);
if (data.title =="Invalid Login")
if (data.title == "Invalid Login")
{
setInvalidLogin(true)
}
} else if (!data) {
console.error('Failed to fetch users.')
}
}
})
Expand Down
19 changes: 11 additions & 8 deletions src/components/notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const Notifications = (user) => {
const queryClient = useQueryClient()
const setUserPerms = setUserInstancePerms()
const numNotifications = useRef(0);
const [errorMsg, setErrorMsg] = useState('');
const [errorMsg, setErrorMsg] = useState({
notif_id: '',
msg: ''
});
let modalRef = useRef();

const { data: notifications} = useQuery({
Expand Down Expand Up @@ -121,11 +124,7 @@ const Notifications = (user) => {
instId: notif.item_id,
permsObj: userPerms,
successFunc: (data) => {
if (!data || data.title == "error")
{
setErrorMsg('Action failed.');
}
else if (data)
if (data && data.status == 200)
{
// Redirect to widget
if (!window.location.pathname.includes('my-widgets'))
Expand All @@ -141,13 +140,17 @@ const Notifications = (user) => {
window.location.hash = notif.item_id + '-collab';
}

setErrorMsg('');
setErrorMsg({notif_id: notif.id, msg: ''});

removeNotification(-1, notif.id);

// Close notifications
setNavOpen(false)
}
else
{
setErrorMsg({notif_id: notif.id, msg: 'Action failed.'});
}
}
})

Expand Down Expand Up @@ -198,7 +201,7 @@ const Notifications = (user) => {
className={`noticeClose ${showDeleteBtn == index ? 'show' : ''}`}
onClick={() => {removeNotification(index)}}
/>
<p id="errorMsg">{errorMsg}</p>
<p className='errorMsg'>{errorMsg.notif_id == notification.id ? errorMsg.msg : ''}</p>
</div>

notificationIcon =
Expand Down
1 change: 1 addition & 0 deletions src/components/profile-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
img {
width: 90px;
height: 90px;
border-radius: 10px;
}

a:link,
Expand Down
4 changes: 2 additions & 2 deletions src/components/user-admin-instance-available.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const UserAdminInstanceAvailable = ({instance, index, currentUser}) => {

return (
<li key={index} className={`instance ${instanceState.expanded ? 'expanded' : ''}`}>
<div className={`clickable widget-title ${instanceState.manager ? 'hidden' : ''}`}
<div className={`clickable widget-title ${instanceState.manager ? 'hidden' : ''}`}
onClick={() => setInstanceState(instanceState => ({...instanceState, expanded: !instanceState.expanded, manager: false}))}>
<span className='img-holder'>
<img src={iconUrl('/widget/', instance.widget.dir, 275)} />
Expand All @@ -53,7 +53,7 @@ const UserAdminInstanceAvailable = ({instance, index, currentUser}) => {
</div>
</span>
</div>
{ !instanceState.manager ?
{ !instanceState.manager ?
<div className={`info-holder`}>
<div>
<span>
Expand Down
Loading

0 comments on commit 44152c3

Please sign in to comment.